a very simple dht node script
This commit is contained in:
parent
2655797692
commit
adcd6edfcb
1 changed files with 39 additions and 0 deletions
39
scripts/simple_dht_node.py
Executable file
39
scripts/simple_dht_node.py
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from lbrynet.core import log_support
|
||||
import logging.handlers
|
||||
import sys
|
||||
import time
|
||||
from pprint import pprint
|
||||
|
||||
from twisted.internet import defer, reactor
|
||||
from lbrynet.dht.node import Node
|
||||
import lbrynet.dht.constants
|
||||
import lbrynet.dht.datastore
|
||||
from lbrynet.tests.util import random_lbry_hash
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def run():
|
||||
node = Node(externalIP='127.0.0.1', udpPort=21215)
|
||||
node.startNetwork()
|
||||
yield node.joinNetwork([("127.0.0.1", 21216)])
|
||||
node2 = Node(externalIP='127.0.0.1', udpPort=21217)
|
||||
node2.startNetwork()
|
||||
yield node2.joinNetwork([("127.0.0.1", 21216)])
|
||||
log.info("Shutting down...")
|
||||
reactor.callLater(0, reactor.stop)
|
||||
|
||||
|
||||
def main():
|
||||
log_support.configure_console(level='DEBUG')
|
||||
log_support.configure_twisted()
|
||||
reactor.callLater(0, run)
|
||||
log.info("Running reactor")
|
||||
reactor.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
Reference in a new issue