[bootstrap] fix bootstrap on localnet failed issue

forget a few changes from master branch

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3142/head
Leo Chen 4 years ago
parent 6b435a8dea
commit e028cc78bc
  1. 5
      cmd/harmony/main.go
  2. 1
      node/node.go
  3. 2
      node/node_handler.go
  4. 5
      p2p/host.go

@ -763,6 +763,11 @@ func main() {
Msg("StartRPC failed") Msg("StartRPC failed")
} }
if err := currentNode.BootstrapConsensus(); err != nil {
fmt.Println("could not bootstrap consensus", err.Error())
os.Exit(-1)
}
if err := currentNode.Start(); err != nil { if err := currentNode.Start(); err != nil {
fmt.Println("could not begin network message handling for node", err.Error()) fmt.Println("could not begin network message handling for node", err.Error())
os.Exit(-1) os.Exit(-1)

@ -524,7 +524,6 @@ func New(
// Setup initial state of syncing. // Setup initial state of syncing.
node.peerRegistrationRecord = map[string]*syncConfig{} node.peerRegistrationRecord = map[string]*syncConfig{}
node.startConsensus = make(chan struct{}) node.startConsensus = make(chan struct{})
go node.BootstrapConsensus()
// Broadcast double-signers reported by consensus // Broadcast double-signers reported by consensus
if node.Consensus != nil { if node.Consensus != nil {
go func() { go func() {

@ -538,8 +538,8 @@ func (node *Node) BootstrapConsensus() error {
go func() { go func() {
node.startConsensus <- struct{}{} node.startConsensus <- struct{}{}
}() }()
}
return nil return nil
}
} }
// ConsensusMessageHandler passes received message in node_handler to consensus // ConsensusMessageHandler passes received message in node_handler to consensus

@ -77,7 +77,10 @@ func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error) {
} }
ctx := context.Background() ctx := context.Background()
p2pHost, err := libp2p.New(ctx, p2pHost, err := libp2p.New(ctx,
libp2p.ListenAddrs(listenAddr), libp2p.Identity(key), libp2p.ListenAddrs(listenAddr),
libp2p.Identity(key),
libp2p.EnableNATService(),
libp2p.ForceReachabilityPublic(),
) )
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "cannot initialize libp2p host") return nil, errors.Wrapf(err, "cannot initialize libp2p host")

Loading…
Cancel
Save