mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-09 15:46:43 +00:00

* [NOD-1098] Change timestamps to be millisecond precision * [NOD-1098] Change lock times to use milliseconds * [NOD-1098] Use milliseconds precision everywhere * [NOD-1098] Implement type mstime.Time * [NOD-1098] Fix block 100000 timestamp * [NOD-1098] Change orphan child to be one millisecond delay after its parent * [NOD-1098] Remove test that checks if header timestamps have the right precision, and instead add tests for mstime, and fix genesis for testnet and devnet * [NOD-1098] Fix comment * [NOD-1098] Fix comment * [NOD-1098] Fix testnet genesis * [NOD-1098] Rename UnixMilli->UnixMilliseconds
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package rpc
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/kaspanet/kaspad/rpcmodel"
|
|
"time"
|
|
)
|
|
|
|
// handleGetConnectedPeerInfo implements the getConnectedPeerInfo command.
|
|
func handleGetConnectedPeerInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
peers := s.cfg.ConnMgr.ConnectedPeers()
|
|
syncPeerID := s.cfg.SyncMgr.SyncPeerID()
|
|
infos := make([]*rpcmodel.GetConnectedPeerInfoResult, 0, len(peers))
|
|
for _, p := range peers {
|
|
statsSnap := p.ToPeer().StatsSnapshot()
|
|
info := &rpcmodel.GetConnectedPeerInfoResult{
|
|
ID: statsSnap.ID,
|
|
Addr: statsSnap.Addr,
|
|
Services: fmt.Sprintf("%08d", uint64(statsSnap.Services)),
|
|
RelayTxes: !p.IsTxRelayDisabled(),
|
|
LastSend: statsSnap.LastSend.UnixMilliseconds(),
|
|
LastRecv: statsSnap.LastRecv.UnixMilliseconds(),
|
|
BytesSent: statsSnap.BytesSent,
|
|
BytesRecv: statsSnap.BytesRecv,
|
|
ConnTime: statsSnap.ConnTime.UnixMilliseconds(),
|
|
PingTime: float64(statsSnap.LastPingMicros),
|
|
TimeOffset: statsSnap.TimeOffset,
|
|
Version: statsSnap.Version,
|
|
SubVer: statsSnap.UserAgent,
|
|
Inbound: statsSnap.Inbound,
|
|
SelectedTip: statsSnap.SelectedTipHash.String(),
|
|
BanScore: int32(p.BanScore()),
|
|
FeeFilter: p.FeeFilter(),
|
|
SyncNode: statsSnap.ID == syncPeerID,
|
|
}
|
|
if p.ToPeer().LastPingNonce() != 0 {
|
|
wait := float64(time.Since(statsSnap.LastPingTime).Nanoseconds())
|
|
// We actually want microseconds.
|
|
info.PingWait = wait / 1000
|
|
}
|
|
infos = append(infos, info)
|
|
}
|
|
return infos, nil
|
|
}
|