MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / addPeer

Method addPeer

src/Site/Site.py:787–805  ·  view source on GitHub ↗
(self, ip, port, return_peer=False, connection=None, source="other")

Source from the content-addressed store, hash-verified

785 # Add or update a peer to site
786 # return_peer: Always return the peer even if it was already present
787 def addPeer(self, ip, port, return_peer=False, connection=None, source="other"):
788 if not ip or ip == "0.0.0.0":
789 return False
790
791 key = "%s:%s" % (ip, port)
792 peer = self.peers.get(key)
793 if peer: # Already has this ip
794 peer.found(source)
795 if return_peer: # Always return peer
796 return peer
797 else:
798 return False
799 else: # New peer
800 if (ip, port) in self.peer_blacklist:
801 return False # Ignore blacklist (eg. myself)
802 peer = Peer(ip, port, self)
803 self.peers[key] = peer
804 peer.found(source)
805 return peer
806
807 def announce(self, *args, **kwargs):
808 self.announcer.announce(*args, **kwargs)

Callers 15

sitePublishMethod · 0.80
processQueryStringMethod · 0.80
announceTrackerMethod · 0.80
addOptionalPeersMethod · 0.80
actionUpdateMethod · 0.80
handleGetFileMethod · 0.80
actionPexMethod · 0.80
actionListModifiedMethod · 0.80
actionGetHashfieldMethod · 0.80
actionSetHashfieldMethod · 0.80
pexMethod · 0.80
testPingMethod · 0.80

Calls 3

foundMethod · 0.95
PeerClass · 0.90
getMethod · 0.45

Tested by 15

testPingMethod · 0.64
testDownloadFileMethod · 0.64
testHashfieldExchangeMethod · 0.64
testFindHashMethod · 0.64
testPexMethod · 0.64
testFindHashMethod · 0.64
testPexMethod · 0.64
testRenameMethod · 0.64
testRenameOptionalMethod · 0.64
testArchivedDownloadMethod · 0.64
testOptionalDownloadMethod · 0.64