mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 08:00:54 +00:00
Add basic support for multiaddr addresses and improvement around peer id (#75)
* Improved peer ID construction and usage * peer id object is directly passed to the network no need to cast from a string to an ID * don't base64 encode the peer id when loading from public key * use proper multiaddr address - keep multiaddr object into peerstore instead of string - update network code to use new multiaddr lib - update tests and example * don't instanciate peerstore object in constructor This has side effect where the same peerstore is used for different instance of Libp2p * add connect method to basic_host * use zaibon's fork of sbuss/py-multiaddr * lint
This commit is contained in:
committed by
Robert Zajac
parent
7fa674dee2
commit
611de28aca
@ -1,5 +1,7 @@
|
||||
from Crypto.PublicKey import RSA
|
||||
import multiaddr
|
||||
from peer.peerstore import PeerStore
|
||||
from peer.id import id_from_public_key
|
||||
from network.swarm import Swarm
|
||||
from host.basic_host import BasicHost
|
||||
from transport.upgrader import TransportUpgrader
|
||||
@ -11,10 +13,11 @@ async def new_node(id_opt=None, transport_opt=None, \
|
||||
|
||||
if id_opt is None:
|
||||
new_key = RSA.generate(2048, e=65537)
|
||||
id_opt = new_key.publickey().exportKey("PEM")
|
||||
id_opt = id_from_public_key(new_key.publickey())
|
||||
# private_key = new_key.exportKey("PEM")
|
||||
|
||||
transport_opt = transport_opt or ["/ip4/127.0.0.1/tcp/8001"]
|
||||
transport_opt = [multiaddr.Multiaddr(t) for t in transport_opt]
|
||||
muxer_opt = muxer_opt or ["mplex/6.7.0"]
|
||||
sec_opt = sec_opt or ["secio"]
|
||||
peerstore = peerstore or PeerStore()
|
||||
|
||||
Reference in New Issue
Block a user