mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
p2p: remove NodeInfo interface and rename DefaultNodeInfo struct (#5799)
The `NodeInfo` interface does not appear to serve any purpose at all, so I removed it and renamed the `DefaultNodeInfo` struct to `NodeInfo` (including the Protobuf representations). Let me know if this is actually needed for anything. Only the Protobuf rename is listed in the changelog, since we do not officially support API stability of the `p2p` package (according to `README.md`). The on-wire protocol remains compatible.
This commit is contained in:
+1
-6
@@ -2,7 +2,6 @@ package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
@@ -16,12 +15,8 @@ func NetInfo(ctx *rpctypes.Context) (*ctypes.ResultNetInfo, error) {
|
||||
peersList := env.P2PPeers.Peers().List()
|
||||
peers := make([]ctypes.Peer, 0, len(peersList))
|
||||
for _, peer := range peersList {
|
||||
nodeInfo, ok := peer.NodeInfo().(p2p.DefaultNodeInfo)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("peer.NodeInfo() is not DefaultNodeInfo")
|
||||
}
|
||||
peers = append(peers, ctypes.Peer{
|
||||
NodeInfo: nodeInfo,
|
||||
NodeInfo: peer.NodeInfo(),
|
||||
IsOutbound: peer.IsOutbound(),
|
||||
ConnectionStatus: peer.Status(),
|
||||
RemoteIP: peer.RemoteIP().String(),
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@@ -52,7 +51,7 @@ func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
|
||||
}
|
||||
|
||||
result := &ctypes.ResultStatus{
|
||||
NodeInfo: env.P2PTransport.NodeInfo().(p2p.DefaultNodeInfo),
|
||||
NodeInfo: env.P2PTransport.NodeInfo(),
|
||||
SyncInfo: ctypes.SyncInfo{
|
||||
LatestBlockHash: latestBlockHash,
|
||||
LatestAppHash: latestAppHash,
|
||||
|
||||
@@ -83,9 +83,9 @@ type ValidatorInfo struct {
|
||||
|
||||
// Node Status
|
||||
type ResultStatus struct {
|
||||
NodeInfo p2p.DefaultNodeInfo `json:"node_info"`
|
||||
SyncInfo SyncInfo `json:"sync_info"`
|
||||
ValidatorInfo ValidatorInfo `json:"validator_info"`
|
||||
NodeInfo p2p.NodeInfo `json:"node_info"`
|
||||
SyncInfo SyncInfo `json:"sync_info"`
|
||||
ValidatorInfo ValidatorInfo `json:"validator_info"`
|
||||
}
|
||||
|
||||
// Is TxIndexing enabled
|
||||
@@ -116,7 +116,7 @@ type ResultDialPeers struct {
|
||||
|
||||
// A peer
|
||||
type Peer struct {
|
||||
NodeInfo p2p.DefaultNodeInfo `json:"node_info"`
|
||||
NodeInfo p2p.NodeInfo `json:"node_info"`
|
||||
IsOutbound bool `json:"is_outbound"`
|
||||
ConnectionStatus p2p.ConnectionStatus `json:"connection_status"`
|
||||
RemoteIP string `json:"remote_ip"`
|
||||
|
||||
@@ -15,17 +15,17 @@ func TestStatusIndexer(t *testing.T) {
|
||||
status = &ResultStatus{}
|
||||
assert.False(t, status.TxIndexEnabled())
|
||||
|
||||
status.NodeInfo = p2p.DefaultNodeInfo{}
|
||||
status.NodeInfo = p2p.NodeInfo{}
|
||||
assert.False(t, status.TxIndexEnabled())
|
||||
|
||||
cases := []struct {
|
||||
expected bool
|
||||
other p2p.DefaultNodeInfoOther
|
||||
other p2p.NodeInfoOther
|
||||
}{
|
||||
{false, p2p.DefaultNodeInfoOther{}},
|
||||
{false, p2p.DefaultNodeInfoOther{TxIndex: "aa"}},
|
||||
{false, p2p.DefaultNodeInfoOther{TxIndex: "off"}},
|
||||
{true, p2p.DefaultNodeInfoOther{TxIndex: "on"}},
|
||||
{false, p2p.NodeInfoOther{}},
|
||||
{false, p2p.NodeInfoOther{TxIndex: "aa"}},
|
||||
{false, p2p.NodeInfoOther{TxIndex: "off"}},
|
||||
{true, p2p.NodeInfoOther{TxIndex: "on"}},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user