Skip to content

Instantly share code, notes, and snippets.

@heikoheiko
Last active August 29, 2015 14:28
Show Gist options
  • Save heikoheiko/7a690f46bb9c0a3b8d33 to your computer and use it in GitHub Desktop.
Save heikoheiko/7a690f46bb9c0a3b8d33 to your computer and use it in GitHub Desktop.
# after entering the console of pyethapp
# https://github.com/ethereum/pyethapp/wiki/The_Console
from devp2p import kademlia
import gevent
def crawl():
delay = 0.1
lookups = 0
kademlia_proto = eth.app.services.discovery.protocol.kademlia
while True:
if lookups % 10 == 0:
print('crawler', len(kademlia_proto.routing), lookups)
nodeid = kademlia.random_nodeid()
kademlia_proto.find_node(nodeid)
gevent.sleep(delay)
lookups += 1
gevent.spawn(crawl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment