diff --git a/CHANGELOG.md b/CHANGELOG.md index f1154baae..e3560666a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/p2p/switch.go b/p2p/switch.go index 5d0bb4f88..ffc1cbb8e 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -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: diff --git a/rpc/core/net.go b/rpc/core/net.go index d3123b9eb..2e931d067 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -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 } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index be7d51f20..1df7038ae 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -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"` }