From 21f2d46e29fd018a10e174f179e033e8626196a5 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Mon, 28 Jan 2019 22:53:26 +0000 Subject: [PATCH] use p2pimpl/host module to init bootnode Signed-off-by: Leo Chen --- cmd/bootnode/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index c300314a7..7d50a3a13 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -3,7 +3,6 @@ package main import ( - "context" "flag" "fmt" "os" @@ -11,6 +10,8 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/harmony-one/harmony/internal/utils" + "github.com/harmony-one/harmony/p2p" + "github.com/harmony-one/harmony/p2p/p2pimpl" libp2p "github.com/libp2p/go-libp2p" crypto "github.com/libp2p/go-libp2p-crypto" ma "github.com/multiformats/go-multiaddr" @@ -77,14 +78,14 @@ func main() { panic(err) } - opts = append(opts, libp2p.Identity(privKey)) + var selfPeer = p2p.Peer{IP: *ip, Port: *port} - host, err := libp2p.New(context.Background(), opts...) + host, err := p2pimpl.NewHost(&selfPeer, privKey, opts...) if err != nil { panic(err) } - log.Info("bootnode", "BN_MA", fmt.Sprintf("/ipv/%s/tcp/%s/p2p/%s", *ip, *port, host.ID().Pretty())) + log.Info("bootnode", "BN_MA", fmt.Sprintf("/ipv/%s/tcp/%s/p2p/%s", *ip, *port, host.GetID().Pretty())) } // saveKey save private key to keyfile