mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Store our pubkey/privkey info during
`initialize_default_swarm`
This commit is contained in:
@ -39,7 +39,6 @@ class BasicHost(IHost):
|
||||
right after a stream is initialized.
|
||||
"""
|
||||
|
||||
_public_key: PublicKey
|
||||
_network: INetwork
|
||||
peerstore: IPeerStore
|
||||
|
||||
@ -48,11 +47,9 @@ class BasicHost(IHost):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
public_key: PublicKey,
|
||||
network: INetwork,
|
||||
default_protocols: "OrderedDict[TProtocol, StreamHandlerFn]" = None,
|
||||
) -> None:
|
||||
self._public_key = public_key
|
||||
self._network = network
|
||||
self._network.set_stream_handler(self._swarm_stream_handler)
|
||||
self.peerstore = self._network.peerstore
|
||||
@ -68,7 +65,7 @@ class BasicHost(IHost):
|
||||
return self._network.get_peer_id()
|
||||
|
||||
def get_public_key(self) -> PublicKey:
|
||||
return self._public_key
|
||||
return self.peerstore.pubkey(self.get_id())
|
||||
|
||||
def get_network(self) -> INetwork:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user