|
|
@ -1,6 +1,7 @@ |
|
|
|
package newnode |
|
|
|
package newnode |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
@ -55,9 +56,9 @@ type registerResponseRandomNumber struct { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ContactBeaconChain starts a newservice in the candidate node
|
|
|
|
// ContactBeaconChain starts a newservice in the candidate node
|
|
|
|
func (node *NewNode) ContactBeaconChain(BCPeer p2p.Peer) { |
|
|
|
func (node *NewNode) ContactBeaconChain(BCPeer p2p.Peer) error { |
|
|
|
go node.host.BindHandlerAndServe(node.NodeHandler) |
|
|
|
go node.host.BindHandlerAndServe(node.NodeHandler) |
|
|
|
node.requestBeaconChain(BCPeer) |
|
|
|
return node.requestBeaconChain(BCPeer) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (node NewNode) String() string { |
|
|
|
func (node NewNode) String() string { |
|
|
@ -65,7 +66,7 @@ func (node NewNode) String() string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RequestBeaconChain requests beacon chain for identity data
|
|
|
|
// RequestBeaconChain requests beacon chain for identity data
|
|
|
|
func (node *NewNode) requestBeaconChain(BCPeer p2p.Peer) { |
|
|
|
func (node *NewNode) requestBeaconChain(BCPeer p2p.Peer) (err error) { |
|
|
|
node.log.Info("connecting to beacon chain now ...") |
|
|
|
node.log.Info("connecting to beacon chain now ...") |
|
|
|
pubk, err := node.PubK.MarshalBinary() |
|
|
|
pubk, err := node.PubK.MarshalBinary() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -94,9 +95,11 @@ checkLoop: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if !gotShardInfo { |
|
|
|
if !gotShardInfo { |
|
|
|
|
|
|
|
err = errors.New("could not create connection") |
|
|
|
node.log.Crit("Could not get sharding info after 5 minutes") |
|
|
|
node.log.Crit("Could not get sharding info after 5 minutes") |
|
|
|
os.Exit(1) |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ProcessShardInfo
|
|
|
|
// ProcessShardInfo
|
|
|
|