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:
parent
4690dd6f00
commit
3aa6f386db
|
@ -326,8 +326,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for i in map(str, items):
|
for i in map(str, items):
|
||||||
Dandelion().addHash(i, self)
|
|
||||||
self.handleReceivedInventory(i)
|
self.handleReceivedInventory(i)
|
||||||
|
Dandelion().addHash(i, self)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ class BMConnectionPool(object):
|
||||||
del i.objectsNewToThem[hashid]
|
del i.objectsNewToThem[hashid]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
if hashid in Dandelion().fluff:
|
||||||
|
Dandelion.removeHash(hashid)
|
||||||
|
|
||||||
def reRandomiseDandelionStems(self):
|
def reRandomiseDandelionStems(self):
|
||||||
# Choose 2 peers randomly
|
# Choose 2 peers randomly
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Dandelion():
|
||||||
self.stem = []
|
self.stem = []
|
||||||
self.nodeMap = {}
|
self.nodeMap = {}
|
||||||
self.hashMap = {}
|
self.hashMap = {}
|
||||||
|
self.fluff = {}
|
||||||
self.timeout = {}
|
self.timeout = {}
|
||||||
self.refresh = time() + REASSIGN_INTERVAL
|
self.refresh = time() + REASSIGN_INTERVAL
|
||||||
self.lock = RLock()
|
self.lock = RLock()
|
||||||
|
@ -37,6 +38,14 @@ class Dandelion():
|
||||||
del self.timeout[hashId]
|
del self.timeout[hashId]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
del self.fluff[hashId]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def fluffTrigger(self, hashId):
|
||||||
|
with self.lock:
|
||||||
|
self.fluff[hashId] = None
|
||||||
|
|
||||||
def maybeAddStem(self, connection):
|
def maybeAddStem(self, connection):
|
||||||
# fewer than MAX_STEMS outbound connections at last reshuffle?
|
# fewer than MAX_STEMS outbound connections at last reshuffle?
|
||||||
|
|
|
@ -82,16 +82,14 @@ class ObjectTracker(object):
|
||||||
del self.objectsNewToThem[hashId]
|
del self.objectsNewToThem[hashId]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
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:
|
if hashId not in missingObjects:
|
||||||
missingObjects[hashId] = time.time()
|
missingObjects[hashId] = time.time()
|
||||||
with self.objectsNewToMeLock:
|
with self.objectsNewToMeLock:
|
||||||
self.objectsNewToMe[hashId] = True
|
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):
|
def hasAddr(self, addr):
|
||||||
if haveBloom:
|
if haveBloom:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user