Browse Source

rpc: add n_peers to /net_info

pull/1519/head
Ethan Buchman 6 years ago
parent
commit
c90bf77566
4 changed files with 11 additions and 4 deletions
  1. +4
    -1
      CHANGELOG.md
  2. +1
    -1
      p2p/switch.go
  3. +5
    -2
      rpc/core/net.go
  4. +1
    -0
      rpc/core/types/responses.go

+ 4
- 1
CHANGELOG.md View File

@ -29,15 +29,18 @@ BUG FIXES:
FEATURES:
- [p2p] Allow peers with different Minor versions to connect
- [rpc] `/net_info` includes `n_peers`
IMPROVEMENTS:
- [p2p] Various code comments cleanup
- [p2p] Various code comments, cleanup, error types
- [p2p] Change some Error logs to Debug
BUG FIXES:
- [p2p] Fix reconnect to persistent peer when first dial fails
- [p2p] Validate NodeInfo.ListenAddr
- [p2p] Only allow (MaxNumPeers - MaxNumOutboundPeers) inbound peers
- [p2p/pex] Limit max msg size to 64kB
## 0.19.1 (April 27th, 2018)


+ 1
- 1
p2p/switch.go View File

@ -401,7 +401,7 @@ func (sw *Switch) DialPeersAsync(addrBook AddrBook, peers []string, persistent b
sw.randomSleep(0)
err := sw.DialPeerWithAddress(addr, persistent)
if err != nil {
switch err.(type) {
switch err {
case ErrSwitchConnectToSelf, ErrSwitchDuplicatePeer:
sw.Logger.Debug("Error dialing peer", "err", err)
default:


+ 5
- 2
rpc/core/net.go View File

@ -23,6 +23,7 @@ import (
// {
// "error": "",
// "result": {
// "n_peers": 0,
// "peers": [],
// "listeners": [
// "Listener(@10.0.2.15:46656)"
@ -47,11 +48,13 @@ func NetInfo() (*ctypes.ResultNetInfo, error) {
ConnectionStatus: peer.Status(),
})
}
// TODO: should we include "num_peers" field for convenience ?
// Let's also include the PersistentPeers and Seeds in here.
// TODO: Should we include PersistentPeers and Seeds in here?
// PRO: useful info
// CON: privacy
return &ctypes.ResultNetInfo{
Listening: listening,
Listeners: listeners,
NPeers: len(peers),
Peers: peers,
}, nil
}


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

@ -100,6 +100,7 @@ func (s *ResultStatus) TxIndexEnabled() bool {
type ResultNetInfo struct {
Listening bool `json:"listening"`
Listeners []string `json:"listeners"`
NPeers int `json:"n_peers"`
Peers []Peer `json:"peers"`
}


Loading…
Cancel
Save