2019-04-21 05:35:05 +08:00
|
|
|
from libp2p.host.basic_host import BasicHost
|
|
|
|
|
|
|
|
class RoutedHost(BasicHost):
|
|
|
|
def __init__(self, _network, _kad_network):
|
|
|
|
super(RoutedHost, self).__init__(_network)
|
|
|
|
self.kad_network = _kad_network
|
|
|
|
|
|
|
|
def get_kad_network(self):
|
|
|
|
return self.kad_network
|
|
|
|
|
2019-04-25 08:59:22 +08:00
|
|
|
def routed_listen(self, port, interface='0.0.0.0'):
|
2019-04-21 05:35:05 +08:00
|
|
|
return self.kad_network.listen(port, interface)
|
|
|
|
|
2019-04-25 08:59:22 +08:00
|
|
|
def routed_get(self, key):
|
2019-04-21 05:35:05 +08:00
|
|
|
return self.kad_network.get(key)
|
|
|
|
|
2019-04-25 08:59:22 +08:00
|
|
|
def routed_set(self, key, value):
|
2019-04-21 05:35:05 +08:00
|
|
|
return self.kad_network.set(key, value)
|
|
|
|
|
2019-04-25 08:59:22 +08:00
|
|
|
def routed_set_digest(self, dkey, value):
|
2019-04-21 05:35:05 +08:00
|
|
|
return self.kad_network.set_digest(dkey, value)
|