Skip to content

Commit

Permalink
Renamed dandelion flag to dandelion_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-skss committed Apr 22, 2024
1 parent 1c8ae8f commit 95af3a8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/bitmessagemain.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def start(self):

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'):
Expand Down
2 changes: 1 addition & 1 deletion src/network/bmproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _command_inv(self, dandelion=False):
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):
Expand Down
2 changes: 1 addition & 1 deletion src/network/dandelion.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def poissonTimeout(start=None, average=0):

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(
Expand Down
4 changes: 2 additions & 2 deletions src/network/invthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def handleLocallyGenerated(stream, hashId):
"""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()
Expand Down Expand Up @@ -77,7 +77,7 @@ def run(self): # pylint: disable=too-many-branches
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:
Expand Down
4 changes: 2 additions & 2 deletions src/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

discoveredPeers = {}

dandelion = 0
dandelion_enabled = 0

kivy = False

Expand Down
2 changes: 1 addition & 1 deletion src/tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_version(self):
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
Expand Down

0 comments on commit 95af3a8

Please sign in to comment.