use p2pimpl/host module to init bootnode

Signed-off-by: Leo Chen <leo@harmony.one>
pull/348/head
Leo Chen 6 years ago
parent 5c129411b1
commit 21f2d46e29
  1. 9
      cmd/bootnode/main.go

@ -3,7 +3,6 @@
package main package main
import ( import (
"context"
"flag" "flag"
"fmt" "fmt"
"os" "os"
@ -11,6 +10,8 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/harmony-one/harmony/internal/utils" "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" libp2p "github.com/libp2p/go-libp2p"
crypto "github.com/libp2p/go-libp2p-crypto" crypto "github.com/libp2p/go-libp2p-crypto"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
@ -77,14 +78,14 @@ func main() {
panic(err) 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 { if err != nil {
panic(err) 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 // saveKey save private key to keyfile

Loading…
Cancel
Save