|
@ -211,28 +211,9 @@ func (n *Node) OnStart() error { |
|
|
|
|
|
|
|
|
// If seeds exist, add them to the address book and dial out
|
|
|
// If seeds exist, add them to the address book and dial out
|
|
|
if n.config.GetString("seeds") != "" { |
|
|
if n.config.GetString("seeds") != "" { |
|
|
seeds := strings.Split(n.config.GetString("seeds"), ",") |
|
|
|
|
|
|
|
|
|
|
|
if n.config.GetBool("pex_reactor") { |
|
|
|
|
|
// add seeds to `addrBook` to avoid losing
|
|
|
|
|
|
ourAddrS := n.NodeInfo().ListenAddr |
|
|
|
|
|
ourAddr, _ := p2p.NewNetAddressString(ourAddrS) |
|
|
|
|
|
for _, s := range seeds { |
|
|
|
|
|
// do not add ourselves
|
|
|
|
|
|
if s == ourAddrS { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addr, err := p2p.NewNetAddressString(s) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
n.addrBook.AddAddress(addr, ourAddr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
n.addrBook.Save() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// dial out
|
|
|
// dial out
|
|
|
if err := n.sw.DialSeeds(seeds); err != nil { |
|
|
|
|
|
|
|
|
seeds := strings.Split(n.config.GetString("seeds"), ",") |
|
|
|
|
|
if err := n.DialSeeds(seeds); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -249,13 +230,6 @@ func (n *Node) OnStart() error { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (n *Node) RunForever() { |
|
|
|
|
|
// Sleep forever and then...
|
|
|
|
|
|
cmn.TrapSignal(func() { |
|
|
|
|
|
n.Stop() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (n *Node) OnStop() { |
|
|
func (n *Node) OnStop() { |
|
|
n.BaseService.OnStop() |
|
|
n.BaseService.OnStop() |
|
|
|
|
|
|
|
@ -271,6 +245,13 @@ func (n *Node) OnStop() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (n *Node) RunForever() { |
|
|
|
|
|
// Sleep forever and then...
|
|
|
|
|
|
cmn.TrapSignal(func() { |
|
|
|
|
|
n.Stop() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Add the event switch to reactors, mempool, etc.
|
|
|
// Add the event switch to reactors, mempool, etc.
|
|
|
func SetEventSwitch(evsw types.EventSwitch, eventables ...types.Eventable) { |
|
|
func SetEventSwitch(evsw types.EventSwitch, eventables ...types.Eventable) { |
|
|
for _, e := range eventables { |
|
|
for _, e := range eventables { |
|
@ -296,6 +277,7 @@ func (n *Node) ConfigureRPC() { |
|
|
rpccore.SetSwitch(n.sw) |
|
|
rpccore.SetSwitch(n.sw) |
|
|
rpccore.SetPubKey(n.privValidator.PubKey) |
|
|
rpccore.SetPubKey(n.privValidator.PubKey) |
|
|
rpccore.SetGenesisDoc(n.genesisDoc) |
|
|
rpccore.SetGenesisDoc(n.genesisDoc) |
|
|
|
|
|
rpccore.SetAddrBook(n.addrBook) |
|
|
rpccore.SetProxyAppQuery(n.proxyApp.Query()) |
|
|
rpccore.SetProxyAppQuery(n.proxyApp.Query()) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -410,8 +392,8 @@ func (n *Node) NodeInfo() *p2p.NodeInfo { |
|
|
return n.sw.NodeInfo() |
|
|
return n.sw.NodeInfo() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (n *Node) DialSeeds(seeds []string) { |
|
|
|
|
|
n.sw.DialSeeds(seeds) |
|
|
|
|
|
|
|
|
func (n *Node) DialSeeds(seeds []string) error { |
|
|
|
|
|
return n.sw.DialSeeds(n.addrBook, seeds) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Defaults to tcp
|
|
|
// Defaults to tcp
|
|
|