Known node count updates
- if too many nodes, only delete oldest nodes in bootstrap provider mode, in normal mode ignore new nodes as it used to before - in bootstrap provider mode, penalise nodes announced by others by 1 day instead of 3 hours
This commit is contained in:
parent
49869d0b56
commit
0529fe2313
|
@ -630,17 +630,18 @@ class receiveDataThread(threading.Thread):
|
|||
knownnodes.knownNodes[recaddrStream] = {}
|
||||
peerFromAddrMessage = state.Peer(hostStandardFormat, recaddrPort)
|
||||
if peerFromAddrMessage not in knownnodes.knownNodes[recaddrStream]:
|
||||
knownnodes.trimKnownNodes(recaddrStream)
|
||||
# only if recent
|
||||
if timeSomeoneElseReceivedMessageFromThisNode > (int(time.time()) - 10800) and timeSomeoneElseReceivedMessageFromThisNode < (int(time.time()) + 10800):
|
||||
logger.debug('added new node ' + str(peerFromAddrMessage) + ' to knownNodes in stream ' + str(recaddrStream))
|
||||
# bootstrap provider?
|
||||
if BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') >= \
|
||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxtotalconnections', 200):
|
||||
knownnodes.trimKnownNodes(recaddrStream)
|
||||
with knownnodes.knownNodesLock:
|
||||
knownnodes.knownNodes[recaddrStream][peerFromAddrMessage] = int(time.time()) - 10800
|
||||
knownnodes.knownNodes[recaddrStream][peerFromAddrMessage] = int(time.time()) - 86400 # penalise initially by 1 day
|
||||
logger.debug('added new node ' + str(peerFromAddrMessage) + ' to knownNodes in stream ' + str(recaddrStream))
|
||||
shared.needToWriteKnownNodesToDisk = True
|
||||
# normal mode
|
||||
else:
|
||||
elif len(knownnodes.knownNodes[recaddrStream]) < 20000:
|
||||
with knownnodes.knownNodesLock:
|
||||
knownnodes.knownNodes[recaddrStream][peerFromAddrMessage] = timeSomeoneElseReceivedMessageFromThisNode
|
||||
hostDetails = (
|
||||
|
@ -648,6 +649,7 @@ class receiveDataThread(threading.Thread):
|
|||
recaddrStream, recaddrServices, hostStandardFormat, recaddrPort)
|
||||
protocol.broadcastToSendDataQueues((
|
||||
recaddrStream, 'advertisepeer', hostDetails))
|
||||
logger.debug('added new node ' + str(peerFromAddrMessage) + ' to knownNodes in stream ' + str(recaddrStream))
|
||||
shared.needToWriteKnownNodesToDisk = True
|
||||
# only update if normal mode
|
||||
elif BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') < \
|
||||
|
|
Loading…
Reference in New Issue
Block a user