Renamed dandelion flag to dandelion_enabled
This commit is contained in:
parent
1c8ae8fef3
commit
95af3a859b
|
@ -156,12 +156,12 @@ class Main(object):
|
||||||
|
|
||||||
set_thread_name("PyBitmessage")
|
set_thread_name("PyBitmessage")
|
||||||
|
|
||||||
state.dandelion = config.safeGetInt('network', 'dandelion')
|
state.dandelion_enabled = config.safeGetInt('network', 'dandelion')
|
||||||
# dandelion requires outbound connections, without them,
|
# dandelion requires outbound connections, without them,
|
||||||
# stem objects will get stuck forever
|
# stem objects will get stuck forever
|
||||||
if state.dandelion and not config.safeGetBoolean(
|
if state.dandelion_enabled and not config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'sendoutgoingconnections'):
|
'bitmessagesettings', 'sendoutgoingconnections'):
|
||||||
state.dandelion = 0
|
state.dandelion_enabled = 0
|
||||||
|
|
||||||
if state.testmode or config.safeGetBoolean(
|
if state.testmode or config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'extralowdifficulty'):
|
'bitmessagesettings', 'extralowdifficulty'):
|
||||||
|
|
|
@ -350,7 +350,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
raise BMProtoExcessiveDataError()
|
raise BMProtoExcessiveDataError()
|
||||||
|
|
||||||
# ignore dinv if dandelion turned off
|
# ignore dinv if dandelion turned off
|
||||||
if dandelion and not state.dandelion:
|
if dandelion and not state.dandelion_enabled:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for i in map(str, items):
|
for i in map(str, items):
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Dandelion: # pylint: disable=old-style-class
|
||||||
|
|
||||||
def addHash(self, hashId, source=None, stream=1):
|
def addHash(self, hashId, source=None, stream=1):
|
||||||
"""Add inventory vector to dandelion stem"""
|
"""Add inventory vector to dandelion stem"""
|
||||||
if not state.dandelion:
|
if not state.dandelion_enabled:
|
||||||
return
|
return
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.hashMap[hashId] = Stem(
|
self.hashMap[hashId] = Stem(
|
||||||
|
|
|
@ -41,7 +41,7 @@ class InvThread(StoppableThread):
|
||||||
"""Locally generated inventory items require special handling"""
|
"""Locally generated inventory items require special handling"""
|
||||||
state.Dandelion.addHash(hashId, stream=stream)
|
state.Dandelion.addHash(hashId, stream=stream)
|
||||||
for connection in BMConnectionPool().connections():
|
for connection in BMConnectionPool().connections():
|
||||||
if state.dandelion and connection != \
|
if state.dandelion_enabled and connection != \
|
||||||
state.Dandelion.objectChildStem(hashId):
|
state.Dandelion.objectChildStem(hashId):
|
||||||
continue
|
continue
|
||||||
connection.objectsNewToThem[hashId] = time()
|
connection.objectsNewToThem[hashId] = time()
|
||||||
|
@ -77,7 +77,7 @@ class InvThread(StoppableThread):
|
||||||
if connection == state.Dandelion.objectChildStem(inv[1]):
|
if connection == state.Dandelion.objectChildStem(inv[1]):
|
||||||
# Fluff trigger by RNG
|
# Fluff trigger by RNG
|
||||||
# auto-ignore if config set to 0, i.e. dandelion is off
|
# 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])
|
fluffs.append(inv[1])
|
||||||
# send a dinv only if the stem node supports dandelion
|
# send a dinv only if the stem node supports dandelion
|
||||||
elif connection.services & protocol.NODE_DANDELION > 0:
|
elif connection.services & protocol.NODE_DANDELION > 0:
|
||||||
|
|
|
@ -351,7 +351,7 @@ def assembleVersionMessage(
|
||||||
'>q',
|
'>q',
|
||||||
NODE_NETWORK
|
NODE_NETWORK
|
||||||
| (NODE_SSL if haveSSL(server) else 0)
|
| (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()))
|
payload += pack('>q', int(time.time()))
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ def assembleVersionMessage(
|
||||||
'>q',
|
'>q',
|
||||||
NODE_NETWORK
|
NODE_NETWORK
|
||||||
| (NODE_SSL if haveSSL(server) else 0)
|
| (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.
|
# = 127.0.0.1. This will be ignored by the remote host.
|
||||||
# The actual remote connected IP will be used.
|
# The actual remote connected IP will be used.
|
||||||
|
|
|
@ -44,7 +44,7 @@ ownAddresses = {}
|
||||||
|
|
||||||
discoveredPeers = {}
|
discoveredPeers = {}
|
||||||
|
|
||||||
dandelion = 0
|
dandelion_enabled = 0
|
||||||
|
|
||||||
kivy = False
|
kivy = False
|
||||||
|
|
||||||
|
|
|
@ -324,7 +324,7 @@ class TestCore(unittest.TestCase):
|
||||||
decoded = self._decode_msg(msg, "IQQiiQlsLv")
|
decoded = self._decode_msg(msg, "IQQiiQlsLv")
|
||||||
peer, _, ua, streams = self._decode_msg(msg, "IQQiiQlsLv")[4:]
|
peer, _, ua, streams = self._decode_msg(msg, "IQQiiQlsLv")[4:]
|
||||||
self.assertEqual(
|
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(ua, '/PyBitmessage:' + softwareVersion + '/')
|
||||||
self.assertEqual(streams, [1])
|
self.assertEqual(streams, [1])
|
||||||
# with multiple streams
|
# with multiple streams
|
||||||
|
|
Reference in New Issue
Block a user