mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
distinguish between seeds and manual peers in the config/flags
- we only use seeds if we can’t connect to peers in the addrbook. - we always connect to nodes given in config/flags Refs #864
This commit is contained in:
@ -94,7 +94,7 @@ Endpoints that require arguments:
|
||||
/broadcast_tx_commit?tx=_
|
||||
/broadcast_tx_sync?tx=_
|
||||
/commit?height=_
|
||||
/dial_seeds?seeds=_
|
||||
/dial_manual_peers?manual_peers=_
|
||||
/subscribe?event=_
|
||||
/tx?hash=_&prove=_
|
||||
/unsafe_start_cpu_profiler?filename=_
|
||||
|
@ -54,18 +54,18 @@ func NetInfo() (*ctypes.ResultNetInfo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
||||
func UnsafeDialManualPeers(manual_peers []string) (*ctypes.ResultDialManualPeers, error) {
|
||||
|
||||
if len(seeds) == 0 {
|
||||
return &ctypes.ResultDialSeeds{}, fmt.Errorf("No seeds provided")
|
||||
if len(manual_peers) == 0 {
|
||||
return &ctypes.ResultDialManualPeers{}, fmt.Errorf("No manual peers provided")
|
||||
}
|
||||
// starts go routines to dial each seed after random delays
|
||||
logger.Info("DialSeeds", "addrBook", addrBook, "seeds", seeds)
|
||||
err := p2pSwitch.DialSeeds(addrBook, seeds)
|
||||
// starts go routines to dial each peer after random delays
|
||||
logger.Info("DialManualPeers", "addrBook", addrBook, "manual_peers", manual_peers)
|
||||
err := p2pSwitch.DialPeersAsync(addrBook, manual_peers, true)
|
||||
if err != nil {
|
||||
return &ctypes.ResultDialSeeds{}, err
|
||||
return &ctypes.ResultDialManualPeers{}, err
|
||||
}
|
||||
return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil
|
||||
return &ctypes.ResultDialManualPeers{"Dialing manual peers in progress. See /net_info for details"}, nil
|
||||
}
|
||||
|
||||
// Get genesis file.
|
||||
|
@ -32,7 +32,7 @@ type P2P interface {
|
||||
NumPeers() (outbound, inbound, dialig int)
|
||||
NodeInfo() *p2p.NodeInfo
|
||||
IsListening() bool
|
||||
DialSeeds(*p2p.AddrBook, []string) error
|
||||
DialPeersAsync(*p2p.AddrBook, []string, bool) error
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
|
@ -38,7 +38,7 @@ var Routes = map[string]*rpc.RPCFunc{
|
||||
|
||||
func AddUnsafeRoutes() {
|
||||
// control API
|
||||
Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds")
|
||||
Routes["dial_manual_peers"] = rpc.NewRPCFunc(UnsafeDialManualPeers, "manual_peers")
|
||||
Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "")
|
||||
|
||||
// profiler API
|
||||
|
@ -82,7 +82,7 @@ type ResultNetInfo struct {
|
||||
Peers []Peer `json:"peers"`
|
||||
}
|
||||
|
||||
type ResultDialSeeds struct {
|
||||
type ResultDialManualPeers struct {
|
||||
Log string `json:"log"`
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user