Renamed dandelion flag to dandelion_enabled

This commit is contained in:
anand k 2024-04-22 08:59:00 +05:30
parent 1c8ae8fef3
commit 95af3a859b
No known key found for this signature in database
GPG Key ID: 515AC24FA525DDE0
7 changed files with 11 additions and 11 deletions

View File

@ -156,12 +156,12 @@ class Main(object):
set_thread_name("PyBitmessage")
state.dandelion = config.safeGetInt('network', 'dandelion')
state.dandelion_enabled = config.safeGetInt('network', 'dandelion')
# dandelion requires outbound connections, without them,
# stem objects will get stuck forever
if state.dandelion and not config.safeGetBoolean(
if state.dandelion_enabled and not config.safeGetBoolean(
'bitmessagesettings', 'sendoutgoingconnections'):
state.dandelion = 0
state.dandelion_enabled = 0
if state.testmode or config.safeGetBoolean(
'bitmessagesettings', 'extralowdifficulty'):

View File

@ -350,7 +350,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
raise BMProtoExcessiveDataError()
# ignore dinv if dandelion turned off
if dandelion and not state.dandelion:
if dandelion and not state.dandelion_enabled:
return True
for i in map(str, items):

View File

@ -49,7 +49,7 @@ class Dandelion: # pylint: disable=old-style-class
def addHash(self, hashId, source=None, stream=1):
"""Add inventory vector to dandelion stem"""
if not state.dandelion:
if not state.dandelion_enabled:
return
with self.lock:
self.hashMap[hashId] = Stem(

View File

@ -41,7 +41,7 @@ class InvThread(StoppableThread):
"""Locally generated inventory items require special handling"""
state.Dandelion.addHash(hashId, stream=stream)
for connection in BMConnectionPool().connections():
if state.dandelion and connection != \
if state.dandelion_enabled and connection != \
state.Dandelion.objectChildStem(hashId):
continue
connection.objectsNewToThem[hashId] = time()
@ -77,7 +77,7 @@ class InvThread(StoppableThread):
if connection == state.Dandelion.objectChildStem(inv[1]):
# Fluff trigger by RNG
# auto-ignore if config set to 0, i.e. dandelion is off
if random.randint(1, 100) >= state.dandelion: # nosec B311
if random.randint(1, 100) >= state.dandelion_enabled: # nosec B311
fluffs.append(inv[1])
# send a dinv only if the stem node supports dandelion
elif connection.services & protocol.NODE_DANDELION > 0:

View File

@ -351,7 +351,7 @@ def assembleVersionMessage(
'>q',
NODE_NETWORK
| (NODE_SSL if haveSSL(server) else 0)
| (NODE_DANDELION if state.dandelion else 0)
| (NODE_DANDELION if state.dandelion_enabled else 0)
)
payload += pack('>q', int(time.time()))
@ -375,7 +375,7 @@ def assembleVersionMessage(
'>q',
NODE_NETWORK
| (NODE_SSL if haveSSL(server) else 0)
| (NODE_DANDELION if state.dandelion else 0)
| (NODE_DANDELION if state.dandelion_enabled else 0)
)
# = 127.0.0.1. This will be ignored by the remote host.
# The actual remote connected IP will be used.

View File

@ -44,7 +44,7 @@ ownAddresses = {}
discoveredPeers = {}
dandelion = 0
dandelion_enabled = 0
kivy = False

View File

@ -324,7 +324,7 @@ class TestCore(unittest.TestCase):
decoded = self._decode_msg(msg, "IQQiiQlsLv")
peer, _, ua, streams = self._decode_msg(msg, "IQQiiQlsLv")[4:]
self.assertEqual(
peer, Node(11 if state.dandelion else 3, '127.0.0.1', 8444))
peer, Node(11 if state.dandelion_enabled else 3, '127.0.0.1', 8444))
self.assertEqual(ua, '/PyBitmessage:' + softwareVersion + '/')
self.assertEqual(streams, [1])
# with multiple streams