Merge pull request #1350 from tendermint/1275-p2p-loopbacks

p2p: loopbacks should be detected and ignored instead of dialling self infinitely
This commit is contained in:
Ethan Buchman
2018-04-06 18:59:05 +03:00
committed by GitHub
9 changed files with 186 additions and 45 deletions

View File

@ -405,9 +405,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