rpc: add n_peers to /net_info
This commit is contained in:
parent
6805ddf1b8
commit
c90bf77566
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue