Browse Source

readd /dial_seeds

pull/1030/head
Anton Kaliaev 7 years ago
parent
commit
1b455883d2
No known key found for this signature in database GPG Key ID: 7B6881D965918214
11 changed files with 36 additions and 8 deletions
  1. +3
    -1
      CHANGELOG.md
  2. +1
    -0
      docs/specification/rpc.rst
  3. +4
    -0
      rpc/client/localclient.go
  4. +4
    -0
      rpc/client/mock/client.go
  5. +1
    -0
      rpc/core/doc.go
  6. +15
    -4
      rpc/core/net.go
  7. +1
    -0
      rpc/core/routes.go
  8. +4
    -0
      rpc/core/types/responses.go
  9. +0
    -0
      test/p2p/pex/dial_persistent_peers.sh
  10. +3
    -3
      test/p2p/pex/test.sh
  11. +0
    -0
      test/p2p/pex/test_dial_persistent_peers.sh

+ 3
- 1
CHANGELOG.md View File

@ -28,10 +28,12 @@ BUG FIXES:
## 0.16.0 (TBD)
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] 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)
BREAKING CHANGES:


+ 1
- 0
docs/specification/rpc.rst 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_sync?tx=_
http://localhost:46657/commit?height=_
http://localhost:46657/dial_seeds?seeds=_
http://localhost:46657/dial_persistent_peers?persistent_peers=_
http://localhost:46657/subscribe?event=_
http://localhost:46657/tx?hash=_&prove=_


+ 4
- 0
rpc/client/localclient.go View File

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


+ 4
- 0
rpc/client/mock/client.go View File

@ -107,6 +107,10 @@ func (c Client) NetInfo() (*ctypes.ResultNetInfo, error) {
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) {
return core.UnsafeDialPersistentPeers(persistent_peers)
}


+ 1
- 0
rpc/core/doc.go View File

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


+ 15
- 4
rpc/core/net.go View File

@ -1,8 +1,7 @@
package core
import (
"fmt"
"github.com/pkg/errors"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
@ -54,10 +53,22 @@ func NetInfo() (*ctypes.ResultNetInfo, error) {
}, 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 {
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
logger.Info("DialPersistentPeers", "addrBook", addrBook, "persistent_peers", persistent_peers)


+ 1
- 0
rpc/core/routes.go View File

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


+ 4
- 0
rpc/core/types/responses.go View File

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


test/p2p/pex/dial_manual_peers.sh → test/p2p/pex/dial_persistent_peers.sh View File


+ 3
- 3
test/p2p/pex/test.sh View File

@ -6,10 +6,10 @@ NETWORK_NAME=$2
N=$3
PROXY_APP=$4
cd $GOPATH/src/github.com/tendermint/tendermint
cd "$GOPATH/src/github.com/tendermint/tendermint"
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"
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"

test/p2p/pex/test_dial_manual_peers.sh → test/p2p/pex/test_dial_persistent_peers.sh View File


Loading…
Cancel
Save