@@ -31,6 +31,7 @@ def __init__(self, sourceNode, storage, ksize, database, signing_key):
3131 self .signing_key = signing_key
3232 self .log = Logger (system = self )
3333 self .handled_commands = [PING , STUN , STORE , DELETE , FIND_NODE , FIND_VALUE , HOLE_PUNCH , INV , VALUES ]
34+ self .recent_transfers = set ()
3435 RPCProtocol .__init__ (self , sourceNode , self .router )
3536
3637 def connect_multiplexer (self , multiplexer ):
@@ -225,7 +226,10 @@ def handleCallResponse(self, result, node):
225226 we get no response, make sure it's removed from the routing table.
226227 """
227228 if result [0 ]:
228- if self .isNewConnection (node ):
229+ if self .isNewConnection (node ) and node .id not in self .recent_transfers :
230+ if len (self .recent_transfers ) == 10 :
231+ self .recent_transfers .pop ()
232+ self .recent_transfers .add (node .id )
229233 self .log .debug ("call response from new node, transferring key/values" )
230234 reactor .callLater (1 , self .transferKeyValues , node )
231235 self .router .addContact (node )
@@ -240,7 +244,10 @@ def addToRouter(self, node):
240244 We add the node to our router and transfer our stored values
241245 if they are new and within our neighborhood.
242246 """
243- if self .isNewConnection (node ):
247+ if self .isNewConnection (node ) and node .id not in self .recent_transfers :
248+ if len (self .recent_transfers ) == 10 :
249+ self .recent_transfers .pop ()
250+ self .recent_transfers .add (node .id )
244251 self .log .debug ("found a new node, transferring key/values" )
245252 reactor .callLater (1 , self .transferKeyValues , node )
246253 self .router .addContact (node )
0 commit comments