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] = {}
|
knownnodes.knownNodes[recaddrStream] = {}
|
||||||
peerFromAddrMessage = state.Peer(hostStandardFormat, recaddrPort)
|
peerFromAddrMessage = state.Peer(hostStandardFormat, recaddrPort)
|
||||||
if peerFromAddrMessage not in knownnodes.knownNodes[recaddrStream]:
|
if peerFromAddrMessage not in knownnodes.knownNodes[recaddrStream]:
|
||||||
knownnodes.trimKnownNodes(recaddrStream)
|
|
||||||
# only if recent
|
# only if recent
|
||||||
if timeSomeoneElseReceivedMessageFromThisNode > (int(time.time()) - 10800) and timeSomeoneElseReceivedMessageFromThisNode < (int(time.time()) + 10800):
|
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?
|
# bootstrap provider?
|
||||||
if BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') >= \
|
if BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') >= \
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxtotalconnections', 200):
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxtotalconnections', 200):
|
||||||
|
knownnodes.trimKnownNodes(recaddrStream)
|
||||||
with knownnodes.knownNodesLock:
|
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
|
# normal mode
|
||||||
else:
|
elif len(knownnodes.knownNodes[recaddrStream]) < 20000:
|
||||||
with knownnodes.knownNodesLock:
|
with knownnodes.knownNodesLock:
|
||||||
knownnodes.knownNodes[recaddrStream][peerFromAddrMessage] = timeSomeoneElseReceivedMessageFromThisNode
|
knownnodes.knownNodes[recaddrStream][peerFromAddrMessage] = timeSomeoneElseReceivedMessageFromThisNode
|
||||||
hostDetails = (
|
hostDetails = (
|
||||||
|
@ -648,7 +649,8 @@ class receiveDataThread(threading.Thread):
|
||||||
recaddrStream, recaddrServices, hostStandardFormat, recaddrPort)
|
recaddrStream, recaddrServices, hostStandardFormat, recaddrPort)
|
||||||
protocol.broadcastToSendDataQueues((
|
protocol.broadcastToSendDataQueues((
|
||||||
recaddrStream, 'advertisepeer', hostDetails))
|
recaddrStream, 'advertisepeer', hostDetails))
|
||||||
shared.needToWriteKnownNodesToDisk = True
|
logger.debug('added new node ' + str(peerFromAddrMessage) + ' to knownNodes in stream ' + str(recaddrStream))
|
||||||
|
shared.needToWriteKnownNodesToDisk = True
|
||||||
# only update if normal mode
|
# only update if normal mode
|
||||||
elif BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') < \
|
elif BMConfigParser().safeGetInt('bitmessagesettings', 'maxoutboundconnections') < \
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'maxtotalconnections', 200):
|
BMConfigParser().safeGetInt('bitmessagesettings', 'maxtotalconnections', 200):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user