readd /dial_seeds

This commit is contained in:
Anton Kaliaev 2018-01-09 16:36:15 -06:00
parent e4897b7bdd
commit 1b455883d2
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
11 changed files with 36 additions and 8 deletions

View File

@ -28,10 +28,12 @@ BUG FIXES:
## 0.16.0 (TBD) ## 0.16.0 (TBD)
BREAKING CHANGES: BREAKING CHANGES:
- rpc: `/unsafe_dial_seeds` renamed to `/unsafe_dial_persistent_peers`
- [p2p] old `seeds` is now `persistent_peers` (persistent peers to which TM will always connect to) - [p2p] old `seeds` is now `persistent_peers` (persistent peers to which TM will always connect to)
- [p2p] now `seeds` only used for getting addresses (if addrbook is empty; not persistent) - [p2p] now `seeds` only used for getting addresses (if addrbook is empty; not persistent)
FEATURES:
- [p2p] added new `/dial_persistent_peers` **unsafe** endpoint
## 0.15.0 (December 29, 2017) ## 0.15.0 (December 29, 2017)
BREAKING CHANGES: BREAKING CHANGES:

View File

@ -111,6 +111,7 @@ An HTTP Get request to the root RPC endpoint (e.g.
http://localhost:46657/broadcast_tx_commit?tx=_ http://localhost:46657/broadcast_tx_commit?tx=_
http://localhost:46657/broadcast_tx_sync?tx=_ http://localhost:46657/broadcast_tx_sync?tx=_
http://localhost:46657/commit?height=_ http://localhost:46657/commit?height=_
http://localhost:46657/dial_seeds?seeds=_
http://localhost:46657/dial_persistent_peers?persistent_peers=_ http://localhost:46657/dial_persistent_peers?persistent_peers=_
http://localhost:46657/subscribe?event=_ http://localhost:46657/subscribe?event=_
http://localhost:46657/tx?hash=_&prove=_ http://localhost:46657/tx?hash=_&prove=_

View File

@ -84,6 +84,10 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
return core.DumpConsensusState() return core.DumpConsensusState()
} }
func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
return core.UnsafeDialSeeds(seeds)
}
func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) {
return core.UnsafeDialPersistentPeers(persistent_peers) return core.UnsafeDialPersistentPeers(persistent_peers)
} }

View File

@ -107,6 +107,10 @@ func (c Client) NetInfo() (*ctypes.ResultNetInfo, error) {
return core.NetInfo() return core.NetInfo()
} }
func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
return core.UnsafeDialSeeds(seeds)
}
func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) {
return core.UnsafeDialPersistentPeers(persistent_peers) return core.UnsafeDialPersistentPeers(persistent_peers)
} }

View File

@ -94,6 +94,7 @@ Endpoints that require arguments:
/broadcast_tx_commit?tx=_ /broadcast_tx_commit?tx=_
/broadcast_tx_sync?tx=_ /broadcast_tx_sync?tx=_
/commit?height=_ /commit?height=_
/dial_seeds?seeds=_
/dial_persistent_peers?persistent_peers=_ /dial_persistent_peers?persistent_peers=_
/subscribe?event=_ /subscribe?event=_
/tx?hash=_&prove=_ /tx?hash=_&prove=_

View File

@ -1,8 +1,7 @@
package core package core
import ( import (
"fmt" "github.com/pkg/errors"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
) )
@ -54,10 +53,22 @@ func NetInfo() (*ctypes.ResultNetInfo, error) {
}, nil }, nil
} }
func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) { func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
if len(seeds) == 0 {
return &ctypes.ResultDialSeeds{}, errors.New("No seeds provided")
}
// starts go routines to dial each peer after random delays
logger.Info("DialSeeds", "addrBook", addrBook, "seeds", seeds)
err := p2pSwitch.DialPeersAsync(addrBook, seeds, false)
if err != nil {
return &ctypes.ResultDialSeeds{}, err
}
return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil
}
func UnsafeDialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) {
if len(persistent_peers) == 0 { if len(persistent_peers) == 0 {
return &ctypes.ResultDialPersistentPeers{}, fmt.Errorf("No persistent peers provided") return &ctypes.ResultDialPersistentPeers{}, errors.New("No persistent peers provided")
} }
// starts go routines to dial each peer after random delays // starts go routines to dial each peer after random delays
logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers) logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers)

View File

@ -38,6 +38,7 @@ var Routes = map[string]*rpc.RPCFunc{
func AddUnsafeRoutes() { func AddUnsafeRoutes() {
// control API // control API
Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds")
Routes["dial_persistent_peers"] = rpc.NewRPCFunc(UnsafeDialPersistentPeers, "persistent_peers") Routes["dial_persistent_peers"] = rpc.NewRPCFunc(UnsafeDialPersistentPeers, "persistent_peers")
Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "") Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "")

View File

@ -82,6 +82,10 @@ type ResultNetInfo struct {
Peers []Peer `json:"peers"` Peers []Peer `json:"peers"`
} }
type ResultDialSeeds struct {
Log string `json:"log"`
}
type ResultDialPersistentPeers struct { type ResultDialPersistentPeers struct {
Log string `json:"log"` Log string `json:"log"`
} }

View File

@ -6,10 +6,10 @@ NETWORK_NAME=$2
N=$3 N=$3
PROXY_APP=$4 PROXY_APP=$4
cd $GOPATH/src/github.com/tendermint/tendermint cd "$GOPATH/src/github.com/tendermint/tendermint"
echo "Test reconnecting from the address book" echo "Test reconnecting from the address book"
bash test/p2p/pex/test_addrbook.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP bash test/p2p/pex/test_addrbook.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP"
echo "Test connecting via /dial_persistent_peers" echo "Test connecting via /dial_persistent_peers"
bash test/p2p/pex/test_dial_persistent_peers.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP bash test/p2p/pex/test_dial_persistent_peers.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP"