MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / updateHashfield

Method updateHashfield

src/Site/Site.py:991–1008  ·  view source on GitHub ↗
(self, limit=5)

Source from the content-addressed store, hash-verified

989
990 # Update hashfield
991 def updateHashfield(self, limit=5):
992 # Return if no optional files
993 if not self.content_manager.hashfield and not self.content_manager.has_optional_files:
994 return False
995
996 s = time.time()
997 queried = 0
998 connected_peers = self.getConnectedPeers()
999 for peer in connected_peers:
1000 if peer.time_hashfield:
1001 continue
1002 if peer.updateHashfield():
1003 queried += 1
1004 if queried >= limit:
1005 break
1006 if queried:
1007 self.log.debug("Queried hashfield from %s peers in %.3fs" % (queried, time.time() - s))
1008 return queried
1009
1010 # Returns if the optional file is need to be downloaded or not
1011 def isDownloadable(self, inner_path):

Callers 4

checkSiteMethod · 0.45
announceSiteMethod · 0.45
testHashfieldExchangeMethod · 0.45
testFindOptionalMethod · 0.45

Calls 1

getConnectedPeersMethod · 0.95

Tested by 2

testHashfieldExchangeMethod · 0.36
testFindOptionalMethod · 0.36