Commit 82050f75 authored by Adrian Sutton's avatar Adrian Sutton

op-node: Include peer scores in rpc peers output

parent 9766f38e
......@@ -5,6 +5,7 @@ import (
"net"
"time"
"github.com/ethereum-optimism/optimism/op-node/p2p/store"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
......@@ -28,6 +29,8 @@ type PeerInfo struct {
Latency time.Duration `json:"latency"`
GossipBlocks bool `json:"gossipBlocks"` // if the peer is in our gossip topic
PeerScores store.PeerScores `json:"scores"`
}
type PeerDump struct {
......
......@@ -8,6 +8,7 @@ import (
"time"
decredSecp "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/ethereum-optimism/optimism/op-node/p2p/store"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p-testing/netutil"
"github.com/libp2p/go-libp2p/core/connmgr"
......@@ -108,6 +109,11 @@ func dumpPeer(id peer.ID, nw network.Network, pstore peerstore.Peerstore, connMg
info.NodeID = enode.PubkeyToIDV4((*decredSecp.PublicKey)(typedPub).ToECDSA())
}
}
if eps, ok := pstore.(store.ExtendedPeerstore); ok {
if dat, err := eps.GetPeerScores(id); err == nil {
info.PeerScores = dat
}
}
if dat, err := pstore.Get(id, "ProtocolVersion"); err == nil {
protocolVersion, ok := dat.(string)
if ok {
......
......@@ -6,7 +6,7 @@ import (
)
type PeerScores struct {
Gossip float64
Gossip float64 `json:"gossip"`
}
type ScoreType int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment