use addrbook#AddOurAddress to store our address

This commit is contained in:
Anton Kaliaev
2018-03-22 16:58:57 +01:00
parent 3284a13fee
commit 3b3f45d49b
5 changed files with 99 additions and 41 deletions

View File

@ -414,9 +414,14 @@ func (n *Node) OnStart() error {
}
n.Logger.Info("P2P Node ID", "ID", nodeKey.ID(), "file", n.config.NodeKeyFile())
// Start the switch
n.sw.SetNodeInfo(n.makeNodeInfo(nodeKey.PubKey()))
nodeInfo := n.makeNodeInfo(nodeKey.PubKey())
n.sw.SetNodeInfo(nodeInfo)
n.sw.SetNodeKey(nodeKey)
// Add ourselves to addrbook to prevent dialing ourselves
n.addrBook.AddOurAddress(nodeInfo.NetAddress())
// Start the switch
err = n.sw.Start()
if err != nil {
return err