Browse Source

dial_persistent_peers -> dial_peers with persistent option

pull/1030/head
Ethan Buchman 7 years ago
parent
commit
e2b3b5b58c
8 changed files with 19 additions and 19 deletions
  1. +1
    -1
      docs/specification/rpc.rst
  2. +4
    -4
      docs/using-tendermint.rst
  3. +1
    -1
      p2p/switch.go
  4. +2
    -2
      rpc/client/localclient.go
  5. +2
    -2
      rpc/client/mock/client.go
  6. +7
    -7
      rpc/core/net.go
  7. +1
    -1
      rpc/core/routes.go
  8. +1
    -1
      rpc/core/types/responses.go

+ 1
- 1
docs/specification/rpc.rst View File

@ -112,7 +112,7 @@ An HTTP Get request to the root RPC endpoint (e.g.
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_seeds?seeds=_
http://localhost:46657/dial_persistent_peers?persistent_peers=_
http://localhost:46657/dial_peers?peers=_&persistent=_
http://localhost:46657/subscribe?event=_ http://localhost:46657/subscribe?event=_
http://localhost:46657/tx?hash=_&prove=_ http://localhost:46657/tx?hash=_&prove=_
http://localhost:46657/unsafe_start_cpu_profiler?filename=_ http://localhost:46657/unsafe_start_cpu_profiler?filename=_


+ 4
- 4
docs/using-tendermint.rst View File

@ -287,7 +287,7 @@ specify seeds for a running node to connect to:
:: ::
curl --data-urlencode "seeds=[\"1.2.3.4:46656\",\"5.6.7.8:46656\"]" localhost:46657/dial_seeds
curl 'localhost:46657/dial_seeds?seeds=\["1.2.3.4:46656","5.6.7.8:46656"\]'
Note, if the peer-exchange protocol (PEX) is enabled (default), you should not Note, if the peer-exchange protocol (PEX) is enabled (default), you should not
normally need seeds after the first start. Peers will be gossipping about known normally need seeds after the first start. Peers will be gossipping about known
@ -296,13 +296,13 @@ peers and forming a network, storing peer addresses in the addrbook.
If you want Tendermint to connect to specific set of addresses and maintain a If you want Tendermint to connect to specific set of addresses and maintain a
persistent connection with each, you can use the ``--p2p.persistent_peers`` persistent connection with each, you can use the ``--p2p.persistent_peers``
flag or the corresponding setting in the ``config.toml`` or the flag or the corresponding setting in the ``config.toml`` or the
``/dial_persistent_peers`` RPC endpoint to do it without stopping Tendermint
``/dial_peers`` RPC endpoint to do it without stopping Tendermint
core instance. core instance.
:: ::
tendermint node --p2p.persistent_peers "10.11.12.13:46656,10.11.12.14:46656" tendermint node --p2p.persistent_peers "10.11.12.13:46656,10.11.12.14:46656"
curl --data-urlencode "persistent_peers=[\"10.11.12.13:46656\",\"10.11.12.14:46656\"]" localhost:46657/dial_persistent_peers
curl 'localhost:46657/dial_peers?persistent=true&peers=\["1.2.3.4:46656","5.6.7.8:46656"\]'
Adding a Non-Validator Adding a Non-Validator
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
@ -382,7 +382,7 @@ and the new ``priv_validator.json`` to the ``~/.tendermint/config`` on a new
machine. machine.
Now run ``tendermint node`` on both machines, and use either Now run ``tendermint node`` on both machines, and use either
``--p2p.persistent_peers`` or the ``/dial_persistent_peers`` to get them to peer up. They
``--p2p.persistent_peers`` or the ``/dial_peers`` to get them to peer up. They
should start making blocks, and will only continue to do so as long as should start making blocks, and will only continue to do so as long as
both of them are online. both of them are online.


+ 1
- 1
p2p/switch.go View File

@ -323,7 +323,7 @@ func (sw *Switch) DialPeersAsync(addrBook *AddrBook, peers []string, persistent
} }
if addrBook != nil { if addrBook != nil {
// add persistent peers to `addrBook`
// add peers to `addrBook`
ourAddrS := sw.nodeInfo.ListenAddr ourAddrS := sw.nodeInfo.ListenAddr
ourAddr, _ := NewNetAddressString(ourAddrS) ourAddr, _ := NewNetAddressString(ourAddrS)
for _, netAddr := range netAddrs { for _, netAddr := range netAddrs {


+ 2
- 2
rpc/client/localclient.go View File

@ -88,8 +88,8 @@ func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
return core.UnsafeDialSeeds(seeds) return core.UnsafeDialSeeds(seeds)
} }
func (Local) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) {
return core.UnsafeDialPersistentPeers(persistent_peers)
func (Local) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) {
return core.UnsafeDialPeers(peers, persistent)
} }
func (Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { func (Local) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {


+ 2
- 2
rpc/client/mock/client.go View File

@ -111,8 +111,8 @@ func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
return core.UnsafeDialSeeds(seeds) return core.UnsafeDialSeeds(seeds)
} }
func (c Client) DialPersistentPeers(persistent_peers []string) (*ctypes.ResultDialPersistentPeers, error) {
return core.UnsafeDialPersistentPeers(persistent_peers)
func (c Client) DialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) {
return core.UnsafeDialPeers(peers, persistent)
} }
func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { func (c Client) BlockchainInfo(minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {


+ 7
- 7
rpc/core/net.go View File

@ -66,17 +66,17 @@ func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil 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{}, errors.New("No persistent peers provided")
func UnsafeDialPeers(peers []string, persistent bool) (*ctypes.ResultDialPeers, error) {
if len(peers) == 0 {
return &ctypes.ResultDialPeers{}, errors.New("No 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)
err := p2pSwitch.DialPeersAsync(addrBook, persistent_peers, true)
logger.Info("DialPeers", "addrBook", addrBook, "peers", peers, "persistent", persistent)
err := p2pSwitch.DialPeersAsync(addrBook, peers, persistent)
if err != nil { if err != nil {
return &ctypes.ResultDialPersistentPeers{}, err
return &ctypes.ResultDialPeers{}, err
} }
return &ctypes.ResultDialPersistentPeers{"Dialing persistent peers in progress. See /net_info for details"}, nil
return &ctypes.ResultDialPeers{"Dialing peers in progress. See /net_info for details"}, nil
} }
// Get genesis file. // Get genesis file.


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

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


+ 1
- 1
rpc/core/types/responses.go View File

@ -86,7 +86,7 @@ type ResultDialSeeds struct {
Log string `json:"log"` Log string `json:"log"`
} }
type ResultDialPersistentPeers struct {
type ResultDialPeers struct {
Log string `json:"log"` Log string `json:"log"`
} }


Loading…
Cancel
Save