mirror of https://github.com/nucypher/nucypher.git
First implementation of customized Server and Protocol classes for DHT. Pending PR 32 on kademlia.
parent
3ed967335b
commit
8f509533c5
|
@ -0,0 +1,17 @@
|
||||||
|
from nkms.network.server import NuCypherDHTServer
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.set_debug(True)
|
||||||
|
loop.set_debug(True)
|
||||||
|
server = NuCypherDHTServer()
|
||||||
|
server.listen(8468)
|
||||||
|
|
||||||
|
try:
|
||||||
|
loop.run_forever()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
|
loop.close()
|
|
@ -0,0 +1,20 @@
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from kademlia.network import Server
|
||||||
|
from nkms.network.protocols import NuCypherSeedOnlyProtocol
|
||||||
|
|
||||||
|
key = "llamas"
|
||||||
|
value = "tons_of_things_keyed_llamas"
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.set_debug(True)
|
||||||
|
|
||||||
|
server = Server(protocol_class=NuCypherSeedOnlyProtocol)
|
||||||
|
server.listen(8469)
|
||||||
|
loop.run_until_complete(server.bootstrap([("127.0.0.1", 8468)]))
|
||||||
|
set = server.set(key, value)
|
||||||
|
loop.run_until_complete(set)
|
||||||
|
server.stop()
|
||||||
|
loop.close()
|
|
@ -0,0 +1,13 @@
|
||||||
|
from kademlia.protocol import KademliaProtocol
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
class NuCypherHashProtocol(KademliaProtocol):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NuCypherSeedOnlyProtocol(NuCypherHashProtocol):
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def _acceptRequest(self, msgID, data, address):
|
||||||
|
pass
|
|
@ -0,0 +1,5 @@
|
||||||
|
from kademlia.network import Server
|
||||||
|
|
||||||
|
|
||||||
|
class NuCypherDHTServer(Server):
|
||||||
|
pass
|
Loading…
Reference in New Issue