Dandelion fixes

- dandelion would always think there is a cycle and trigger fluff
- cycle fluff trigger didn't correctly re-download and re-announce the
object. Now it remembers between (d)inv and object commands that it's
in a fluff trigger phase.
This commit is contained in:
Peter Šurda 2017-11-18 09:47:17 +01:00
parent 4690dd6f00
commit 3aa6f386db
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
4 changed files with 16 additions and 7 deletions

View File

@ -326,8 +326,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
return True
for i in map(str, items):
Dandelion().addHash(i, self)
self.handleReceivedInventory(i)
Dandelion().addHash(i, self)
return True

View File

@ -51,6 +51,8 @@ class BMConnectionPool(object):
del i.objectsNewToThem[hashid]
except KeyError:
pass
if hashid in Dandelion().fluff:
Dandelion.removeHash(hashid)
def reRandomiseDandelionStems(self):
# Choose 2 peers randomly

View File

@ -16,6 +16,7 @@ class Dandelion():
self.stem = []
self.nodeMap = {}
self.hashMap = {}
self.fluff = {}
self.timeout = {}
self.refresh = time() + REASSIGN_INTERVAL
self.lock = RLock()
@ -37,6 +38,14 @@ class Dandelion():
del self.timeout[hashId]
except KeyError:
pass
try:
del self.fluff[hashId]
except KeyError:
pass
def fluffTrigger(self, hashId):
with self.lock:
self.fluff[hashId] = None
def maybeAddStem(self, connection):
# fewer than MAX_STEMS outbound connections at last reshuffle?

View File

@ -82,16 +82,14 @@ class ObjectTracker(object):
del self.objectsNewToThem[hashId]
except KeyError:
pass
if hashId not in Inventory():
# Fluff trigger by cycle detection
if hashId not in Inventory() or hashId in Dandelion().hashMap:
if hashId in Dandelion().hashMap:
Dandelion().fluffTrigger(hashId)
if hashId not in missingObjects:
missingObjects[hashId] = time.time()
with self.objectsNewToMeLock:
self.objectsNewToMe[hashId] = True
elif hashId in Dandelion().hashMap:
# Fluff trigger by cycle detection
Dandelion().removeHash(hashId)
with self.objectsNewToMeLock:
self.objectsNewToMe[hashId] = True
def hasAddr(self, addr):
if haveBloom: