You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
948 B
33 lines
948 B
package wiki
|
|
|
|
import (
|
|
nodeconfig "github.com/woop-chain/woop/internal/configs/node"
|
|
commonRPC "github.com/woop-chain/woop/rpc/common"
|
|
"github.com/woop-chain/woop/staking/network"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
)
|
|
|
|
// GetCurrentUtilityMetrics ..
|
|
func (wiki *Woop) GetCurrentUtilityMetrics() (*network.UtilityMetric, error) {
|
|
return network.NewUtilityMetricSnapshot(wiki.BlockChain)
|
|
}
|
|
|
|
// GetPeerInfo returns the peer info to the node, including blocked peer, connected peer, number of peers
|
|
func (wiki *Woop) GetPeerInfo() commonRPC.NodePeerInfo {
|
|
|
|
topics := wiki.NodeAPI.ListTopic()
|
|
p := make([]commonRPC.P, len(topics))
|
|
|
|
for i, t := range topics {
|
|
topicPeer := wiki.NodeAPI.ListPeer(t)
|
|
p[i].Topic = t
|
|
p[i].Peers = make([]peer.ID, len(topicPeer))
|
|
copy(p[i].Peers, topicPeer)
|
|
}
|
|
|
|
return commonRPC.NodePeerInfo{
|
|
PeerID: nodeconfig.GetPeerID(),
|
|
BlockedPeers: wiki.NodeAPI.ListBlockedPeer(),
|
|
P: p,
|
|
}
|
|
}
|
|
|