Beispiel #1
0
 def nodeSeen( self, nodeAddr, nodeNumId=None ) :
     if nodeNumId is None :
         nodeNumId = idToNum( addrToId(nodeAddr) )
     if nodeNumId == self.selfNumId : return
     for i,bucket in enumerate(self.table) :
         if bucket.contains(nodeNumId) : break
     if not bucket.contains(self.selfNumId) :
         bucket.addNode( nodeAddr, nodeNumId )
     else :
         self.table[i:i+1] = bucket.split()
         self.nodeSeen( nodeAddr, nodeNumId )
Beispiel #2
0
 def nodeSeen(self, nodeAddr, nodeNumId=None):
     if nodeNumId is None:
         nodeNumId = idToNum(addrToId(nodeAddr))
     if nodeNumId == self.selfNumId: return
     for i, bucket in enumerate(self.table):
         if bucket.contains(nodeNumId): break
     if not bucket.contains(self.selfNumId):
         bucket.addNode(nodeAddr, nodeNumId)
     else:
         self.table[i:i + 1] = bucket.split()
         self.nodeSeen(nodeAddr, nodeNumId)
Beispiel #3
0
 def __init__( self, rpcSocket, reactor, knownNodes=[] ) :
     self.rpcSocket = rpcSocket
     self.reactor = reactor
     self.rpcSocket.setRequestCallback( self._onInput )
     self.store = DataStore()
     self.ktable = KTable( idToNum(addrToId(rpcSocket.getAddr())) )
     self.ktracker = KTracker( self.ktable )
     for nodeAddr in knownNodes :
         self.ktable.nodeSeen( nodeAddr )
     self.client = DHTClient( rpcSocket, False, self.ktracker )
     self.requestTable = {}
     for x in MESSAGES :
         self.requestTable[x] = getattr( self, 'do%s' % x )
     self.otherOps = set()
     self._initNodeRefresher()
     self._initDataTimer()
Beispiel #4
0
 def __init__(self, rpcSocket, reactor, knownNodes=[]):
     self.rpcSocket = rpcSocket
     self.reactor = reactor
     self.rpcSocket.setRequestCallback(self._onInput)
     self.store = DataStore()
     self.ktable = KTable(idToNum(addrToId(rpcSocket.getAddr())))
     self.ktracker = KTracker(self.ktable)
     for nodeAddr in knownNodes:
         self.ktable.nodeSeen(nodeAddr)
     self.client = DHTClient(rpcSocket, False, self.ktracker)
     self.requestTable = {}
     for x in MESSAGES:
         self.requestTable[x] = getattr(self, 'do%s' % x)
     self.otherOps = set()
     self._initNodeRefresher()
     self._initDataTimer()
Beispiel #5
0
 def __init__(self, nodeAddr, destNumId):
     self.nodeAddr = nodeAddr
     self.numId = idToNum(addrToId(nodeAddr))
     self.distance = destNumId ^ self.numId
Beispiel #6
0
 def __init__( self, nodeAddr, destNumId ) :
     self.nodeAddr = nodeAddr
     self.numId = idToNum(addrToId(nodeAddr))
     self.distance = destNumId ^ self.numId