Browse Source

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.
pull/5803/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
e198edf20e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 208 additions and 256 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +1
    -1
      blockchain/v2/reactor_test.go
  3. +3
    -3
      node/node.go
  4. +1
    -1
      node/node_test.go
  5. +1
    -1
      p2p/mock/peer.go
  6. +20
    -52
      p2p/node_info.go
  7. +40
    -45
      p2p/node_info_test.go
  8. +1
    -1
      p2p/peer_set_test.go
  9. +1
    -1
      p2p/peer_test.go
  10. +10
    -16
      p2p/test_util.go
  11. +1
    -1
      p2p/transport.go
  12. +9
    -9
      p2p/transport_mconn.go
  13. +94
    -94
      proto/tendermint/p2p/types.pb.go
  14. +10
    -10
      proto/tendermint/p2p/types.proto
  15. +1
    -6
      rpc/core/net.go
  16. +1
    -2
      rpc/core/status.go
  17. +4
    -4
      rpc/core/types/responses.go
  18. +6
    -6
      rpc/core/types/responses_test.go
  19. +3
    -3
      test/maverick/node/node.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -24,6 +24,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [abci/client, proxy] \#5673 `Async` funcs return an error, `Sync` and `Async` funcs accept `context.Context` (@melekes)
- [p2p] Removed unused function `MakePoWTarget`. (@erikgrinaker)
- [libs/bits] \#5720 Validate `BitArray` in `FromProto`, which now returns an error (@melekes)
- [proto/p2p] Renamed `DefaultNodeInfo` and `DefaultNodeInfoOther` to `NodeInfo` and `NodeInfoOther` (@erikgrinaker)
- [libs/os] Kill() and {Must,}{Read,Write}File() functions have been removed. (@alessio)


+ 1
- 1
blockchain/v2/reactor_test.go View File

@ -45,7 +45,7 @@ func (mp mockPeer) IsPersistent() bool { return true }
func (mp mockPeer) CloseConn() error { return nil }
func (mp mockPeer) NodeInfo() p2p.NodeInfo {
return p2p.DefaultNodeInfo{
return p2p.NodeInfo{
DefaultNodeID: "",
ListenAddr: "",
}


+ 3
- 3
node/node.go View File

@ -1256,10 +1256,10 @@ func makeNodeInfo(
case "v2":
bcChannel = bcv2.BlockchainChannel
default:
return nil, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version)
return p2p.NodeInfo{}, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version)
}
nodeInfo := p2p.DefaultNodeInfo{
nodeInfo := p2p.NodeInfo{
ProtocolVersion: p2p.NewProtocolVersion(
version.P2PProtocol, // global
state.Version.Consensus.Block,
@ -1276,7 +1276,7 @@ func makeNodeInfo(
byte(statesync.SnapshotChannel), byte(statesync.ChunkChannel),
},
Moniker: config.Moniker,
Other: p2p.DefaultNodeInfoOther{
Other: p2p.NodeInfoOther{
TxIndex: txIndexerStatus,
RPCAddress: config.RPC.ListenAddress,
},


+ 1
- 1
node/node_test.go View File

@ -131,7 +131,7 @@ func TestNodeSetAppVersion(t *testing.T) {
assert.Equal(t, state.Version.Consensus.App, appVersion)
// check version is set in node info
assert.Equal(t, n.nodeInfo.(p2p.DefaultNodeInfo).ProtocolVersion.App, appVersion)
assert.Equal(t, n.nodeInfo.ProtocolVersion.App, appVersion)
}
func TestNodeSetPrivValTCP(t *testing.T) {


+ 1
- 1
p2p/mock/peer.go View File

@ -45,7 +45,7 @@ func (mp *Peer) FlushStop() { mp.Stop() } //nolint:
func (mp *Peer) TrySend(chID byte, msgBytes []byte) bool { return true }
func (mp *Peer) Send(chID byte, msgBytes []byte) bool { return true }
func (mp *Peer) NodeInfo() p2p.NodeInfo {
return p2p.DefaultNodeInfo{
return p2p.NodeInfo{
DefaultNodeID: mp.addr.ID,
ListenAddr: mp.addr.DialString(),
}


+ 20
- 52
p2p/node_info.go View File

@ -3,7 +3,6 @@ package p2p
import (
"errors"
"fmt"
"reflect"
"github.com/tendermint/tendermint/libs/bytes"
tmstrings "github.com/tendermint/tendermint/libs/strings"
@ -21,29 +20,6 @@ func MaxNodeInfoSize() int {
return maxNodeInfoSize
}
//-------------------------------------------------------------
// NodeInfo exposes basic info of a node
// and determines if we're compatible.
type NodeInfo interface {
ID() ID
nodeInfoAddress
nodeInfoTransport
}
type nodeInfoAddress interface {
NetAddress() (*NetAddress, error)
}
// nodeInfoTransport validates a nodeInfo and checks
// our compatibility with it. It's for use in the handshake.
type nodeInfoTransport interface {
Validate() error
CompatibleWith(other NodeInfo) error
}
//-------------------------------------------------------------
// ProtocolVersion contains the protocol versions for the software.
type ProtocolVersion struct {
P2P uint64 `json:"p2p"`
@ -70,12 +46,9 @@ func NewProtocolVersion(p2p, block, app uint64) ProtocolVersion {
//-------------------------------------------------------------
// Assert DefaultNodeInfo satisfies NodeInfo
var _ NodeInfo = DefaultNodeInfo{}
// DefaultNodeInfo is the basic node information exchanged
// NodeInfo is the basic node information exchanged
// between two peers during the Tendermint P2P handshake.
type DefaultNodeInfo struct {
type NodeInfo struct {
ProtocolVersion ProtocolVersion `json:"protocol_version"`
// Authenticate
@ -90,22 +63,22 @@ type DefaultNodeInfo struct {
Channels bytes.HexBytes `json:"channels"` // channels this node knows about
// ASCIIText fields
Moniker string `json:"moniker"` // arbitrary moniker
Other DefaultNodeInfoOther `json:"other"` // other application specific data
Moniker string `json:"moniker"` // arbitrary moniker
Other NodeInfoOther `json:"other"` // other application specific data
}
// DefaultNodeInfoOther is the misc. applcation specific data
type DefaultNodeInfoOther struct {
// NodeInfoOther is the misc. applcation specific data
type NodeInfoOther struct {
TxIndex string `json:"tx_index"`
RPCAddress string `json:"rpc_address"`
}
// ID returns the node's peer ID.
func (info DefaultNodeInfo) ID() ID {
func (info NodeInfo) ID() ID {
return info.DefaultNodeID
}
// Validate checks the self-reported DefaultNodeInfo is safe.
// Validate checks the self-reported NodeInfo is safe.
// It returns an error if there
// are too many Channels, if there are any duplicate Channels,
// if the ListenAddr is malformed, or if the ListenAddr is a host name
@ -118,7 +91,7 @@ func (info DefaultNodeInfo) ID() ID {
// International clients could then use punycode (or we could use
// url-encoding), and we just need to be careful with how we handle that in our
// clients. (e.g. off by default).
func (info DefaultNodeInfo) Validate() error {
func (info NodeInfo) Validate() error {
// ID is already validated.
@ -172,15 +145,10 @@ func (info DefaultNodeInfo) Validate() error {
return nil
}
// CompatibleWith checks if two DefaultNodeInfo are compatible with eachother.
// CompatibleWith checks if two NodeInfo are compatible with each other.
// CONTRACT: two nodes are compatible if the Block version and network match
// and they have at least one channel in common.
func (info DefaultNodeInfo) CompatibleWith(otherInfo NodeInfo) error {
other, ok := otherInfo.(DefaultNodeInfo)
if !ok {
return fmt.Errorf("wrong NodeInfo type. Expected DefaultNodeInfo, got %v", reflect.TypeOf(otherInfo))
}
func (info NodeInfo) CompatibleWith(other NodeInfo) error {
if info.ProtocolVersion.Block != other.ProtocolVersion.Block {
return fmt.Errorf("peer is on a different Block version. Got %v, expected %v",
other.ProtocolVersion.Block, info.ProtocolVersion.Block)
@ -213,18 +181,18 @@ OUTER_LOOP:
return nil
}
// NetAddress returns a NetAddress derived from the DefaultNodeInfo -
// NetAddress returns a NetAddress derived from the NodeInfo -
// it includes the authenticated peer ID and the self-reported
// ListenAddr. Note that the ListenAddr is not authenticated and
// may not match that address actually dialed if its an outbound peer.
func (info DefaultNodeInfo) NetAddress() (*NetAddress, error) {
func (info NodeInfo) NetAddress() (*NetAddress, error) {
idAddr := IDAddressString(info.ID(), info.ListenAddr)
return NewNetAddressString(idAddr)
}
func (info DefaultNodeInfo) ToProto() *tmp2p.DefaultNodeInfo {
func (info NodeInfo) ToProto() *tmp2p.NodeInfo {
dni := new(tmp2p.DefaultNodeInfo)
dni := new(tmp2p.NodeInfo)
dni.ProtocolVersion = tmp2p.ProtocolVersion{
P2P: info.ProtocolVersion.P2P,
Block: info.ProtocolVersion.Block,
@ -237,7 +205,7 @@ func (info DefaultNodeInfo) ToProto() *tmp2p.DefaultNodeInfo {
dni.Version = info.Version
dni.Channels = info.Channels
dni.Moniker = info.Moniker
dni.Other = tmp2p.DefaultNodeInfoOther{
dni.Other = tmp2p.NodeInfoOther{
TxIndex: info.Other.TxIndex,
RPCAddress: info.Other.RPCAddress,
}
@ -245,11 +213,11 @@ func (info DefaultNodeInfo) ToProto() *tmp2p.DefaultNodeInfo {
return dni
}
func DefaultNodeInfoFromProto(pb *tmp2p.DefaultNodeInfo) (DefaultNodeInfo, error) {
func NodeInfoFromProto(pb *tmp2p.NodeInfo) (NodeInfo, error) {
if pb == nil {
return DefaultNodeInfo{}, errors.New("nil node info")
return NodeInfo{}, errors.New("nil node info")
}
dni := DefaultNodeInfo{
dni := NodeInfo{
ProtocolVersion: ProtocolVersion{
P2P: pb.ProtocolVersion.P2P,
Block: pb.ProtocolVersion.Block,
@ -261,7 +229,7 @@ func DefaultNodeInfoFromProto(pb *tmp2p.DefaultNodeInfo) (DefaultNodeInfo, error
Version: pb.Version,
Channels: pb.Channels,
Moniker: pb.Moniker,
Other: DefaultNodeInfoOther{
Other: NodeInfoOther{
TxIndex: pb.Other.TxIndex,
RPCAddress: pb.Other.RPCAddress,
},


+ 40
- 45
p2p/node_info_test.go View File

@ -9,7 +9,7 @@ import (
func TestNodeInfoValidate(t *testing.T) {
// empty fails
ni := DefaultNodeInfo{}
ni := NodeInfo{}
assert.Error(t, ni.Validate())
channels := make([]byte, maxNumChannels)
@ -26,54 +26,54 @@ func TestNodeInfoValidate(t *testing.T) {
testCases := []struct {
testName string
malleateNodeInfo func(*DefaultNodeInfo)
malleateNodeInfo func(*NodeInfo)
expectErr bool
}{
{
"Too Many Channels",
func(ni *DefaultNodeInfo) { ni.Channels = append(channels, byte(maxNumChannels)) }, // nolint: gocritic
func(ni *NodeInfo) { ni.Channels = append(channels, byte(maxNumChannels)) }, // nolint: gocritic
true,
},
{"Duplicate Channel", func(ni *DefaultNodeInfo) { ni.Channels = dupChannels }, true},
{"Good Channels", func(ni *DefaultNodeInfo) { ni.Channels = ni.Channels[:5] }, false},
{"Invalid NetAddress", func(ni *DefaultNodeInfo) { ni.ListenAddr = "not-an-address" }, true},
{"Good NetAddress", func(ni *DefaultNodeInfo) { ni.ListenAddr = "0.0.0.0:26656" }, false},
{"Non-ASCII Version", func(ni *DefaultNodeInfo) { ni.Version = nonASCII }, true},
{"Empty tab Version", func(ni *DefaultNodeInfo) { ni.Version = emptyTab }, true},
{"Empty space Version", func(ni *DefaultNodeInfo) { ni.Version = emptySpace }, true},
{"Empty Version", func(ni *DefaultNodeInfo) { ni.Version = "" }, false},
{"Non-ASCII Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = nonASCII }, true},
{"Empty tab Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = emptyTab }, true},
{"Empty space Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = emptySpace }, true},
{"Empty Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = "" }, true},
{"Good Moniker", func(ni *DefaultNodeInfo) { ni.Moniker = "hey its me" }, false},
{"Non-ASCII TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = nonASCII }, true},
{"Empty tab TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = emptyTab }, true},
{"Empty space TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = emptySpace }, true},
{"Empty TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = "" }, false},
{"Off TxIndex", func(ni *DefaultNodeInfo) { ni.Other.TxIndex = "off" }, false},
{"Non-ASCII RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = nonASCII }, true},
{"Empty tab RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = emptyTab }, true},
{"Empty space RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = emptySpace }, true},
{"Empty RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = "" }, false},
{"Good RPCAddress", func(ni *DefaultNodeInfo) { ni.Other.RPCAddress = "0.0.0.0:26657" }, false},
{"Duplicate Channel", func(ni *NodeInfo) { ni.Channels = dupChannels }, true},
{"Good Channels", func(ni *NodeInfo) { ni.Channels = ni.Channels[:5] }, false},
{"Invalid NetAddress", func(ni *NodeInfo) { ni.ListenAddr = "not-an-address" }, true},
{"Good NetAddress", func(ni *NodeInfo) { ni.ListenAddr = "0.0.0.0:26656" }, false},
{"Non-ASCII Version", func(ni *NodeInfo) { ni.Version = nonASCII }, true},
{"Empty tab Version", func(ni *NodeInfo) { ni.Version = emptyTab }, true},
{"Empty space Version", func(ni *NodeInfo) { ni.Version = emptySpace }, true},
{"Empty Version", func(ni *NodeInfo) { ni.Version = "" }, false},
{"Non-ASCII Moniker", func(ni *NodeInfo) { ni.Moniker = nonASCII }, true},
{"Empty tab Moniker", func(ni *NodeInfo) { ni.Moniker = emptyTab }, true},
{"Empty space Moniker", func(ni *NodeInfo) { ni.Moniker = emptySpace }, true},
{"Empty Moniker", func(ni *NodeInfo) { ni.Moniker = "" }, true},
{"Good Moniker", func(ni *NodeInfo) { ni.Moniker = "hey its me" }, false},
{"Non-ASCII TxIndex", func(ni *NodeInfo) { ni.Other.TxIndex = nonASCII }, true},
{"Empty tab TxIndex", func(ni *NodeInfo) { ni.Other.TxIndex = emptyTab }, true},
{"Empty space TxIndex", func(ni *NodeInfo) { ni.Other.TxIndex = emptySpace }, true},
{"Empty TxIndex", func(ni *NodeInfo) { ni.Other.TxIndex = "" }, false},
{"Off TxIndex", func(ni *NodeInfo) { ni.Other.TxIndex = "off" }, false},
{"Non-ASCII RPCAddress", func(ni *NodeInfo) { ni.Other.RPCAddress = nonASCII }, true},
{"Empty tab RPCAddress", func(ni *NodeInfo) { ni.Other.RPCAddress = emptyTab }, true},
{"Empty space RPCAddress", func(ni *NodeInfo) { ni.Other.RPCAddress = emptySpace }, true},
{"Empty RPCAddress", func(ni *NodeInfo) { ni.Other.RPCAddress = "" }, false},
{"Good RPCAddress", func(ni *NodeInfo) { ni.Other.RPCAddress = "0.0.0.0:26657" }, false},
}
nodeKey := GenNodeKey()
name := "testing"
// test case passes
ni = testNodeInfo(nodeKey.ID, name).(DefaultNodeInfo)
ni = testNodeInfo(nodeKey.ID, name)
ni.Channels = channels
assert.NoError(t, ni.Validate())
for _, tc := range testCases {
ni := testNodeInfo(nodeKey.ID, name).(DefaultNodeInfo)
ni := testNodeInfo(nodeKey.ID, name)
ni.Channels = channels
tc.malleateNodeInfo(&ni)
err := ni.Validate()
@ -95,30 +95,25 @@ func TestNodeInfoCompatible(t *testing.T) {
var newTestChannel byte = 0x2
// test NodeInfo is compatible
ni1 := testNodeInfo(nodeKey1.ID, name).(DefaultNodeInfo)
ni2 := testNodeInfo(nodeKey2.ID, name).(DefaultNodeInfo)
ni1 := testNodeInfo(nodeKey1.ID, name)
ni2 := testNodeInfo(nodeKey2.ID, name)
assert.NoError(t, ni1.CompatibleWith(ni2))
// add another channel; still compatible
ni2.Channels = []byte{newTestChannel, testCh}
assert.NoError(t, ni1.CompatibleWith(ni2))
// wrong NodeInfo type is not compatible
_, netAddr := CreateRoutableAddr()
ni3 := mockNodeInfo{netAddr}
assert.Error(t, ni1.CompatibleWith(ni3))
testCases := []struct {
testName string
malleateNodeInfo func(*DefaultNodeInfo)
malleateNodeInfo func(*NodeInfo)
}{
{"Wrong block version", func(ni *DefaultNodeInfo) { ni.ProtocolVersion.Block++ }},
{"Wrong network", func(ni *DefaultNodeInfo) { ni.Network += "-wrong" }},
{"No common channels", func(ni *DefaultNodeInfo) { ni.Channels = []byte{newTestChannel} }},
{"Wrong block version", func(ni *NodeInfo) { ni.ProtocolVersion.Block++ }},
{"Wrong network", func(ni *NodeInfo) { ni.Network += "-wrong" }},
{"No common channels", func(ni *NodeInfo) { ni.Channels = []byte{newTestChannel} }},
}
for _, tc := range testCases {
ni := testNodeInfo(nodeKey2.ID, name).(DefaultNodeInfo)
ni := testNodeInfo(nodeKey2.ID, name)
tc.malleateNodeInfo(&ni)
assert.Error(t, ni1.CompatibleWith(ni))
}


+ 1
- 1
p2p/peer_set_test.go View File

@ -20,7 +20,7 @@ type mockPeer struct {
func (mp *mockPeer) FlushStop() { mp.Stop() } //nolint:errcheck // ignore error
func (mp *mockPeer) TrySend(chID byte, msgBytes []byte) bool { return true }
func (mp *mockPeer) Send(chID byte, msgBytes []byte) bool { return true }
func (mp *mockPeer) NodeInfo() NodeInfo { return DefaultNodeInfo{} }
func (mp *mockPeer) NodeInfo() NodeInfo { return NodeInfo{} }
func (mp *mockPeer) Status() ConnectionStatus { return ConnectionStatus{} }
func (mp *mockPeer) ID() ID { return mp.id }
func (mp *mockPeer) IsOutbound() bool { return false }


+ 1
- 1
p2p/peer_test.go View File

@ -260,7 +260,7 @@ func (rp *remotePeer) accept() {
}
func (rp *remotePeer) nodeInfo() NodeInfo {
return DefaultNodeInfo{
return NodeInfo{
ProtocolVersion: defaultProtocolVersion,
DefaultNodeID: rp.Addr().ID,
ListenAddr: rp.listener.Addr().String(),


+ 10
- 16
p2p/test_util.go View File

@ -16,15 +16,6 @@ const testCh = 0x01
//------------------------------------------------
type mockNodeInfo struct {
addr *NetAddress
}
func (ni mockNodeInfo) ID() ID { return ni.addr.ID }
func (ni mockNodeInfo) NetAddress() (*NetAddress, error) { return ni.addr, nil }
func (ni mockNodeInfo) Validate() error { return nil }
func (ni mockNodeInfo) CompatibleWith(other NodeInfo) error { return nil }
func AddPeerToSwitchPeerSet(sw *Switch, peer Peer) {
sw.peers.Add(peer) //nolint:errcheck // ignore error
}
@ -33,8 +24,11 @@ func CreateRandomPeer(outbound bool) Peer {
addr, netAddr := CreateRoutableAddr()
p := &peer{
peerConn: peerConn{outbound: outbound},
nodeInfo: mockNodeInfo{netAddr},
metrics: NopMetrics(),
nodeInfo: NodeInfo{
DefaultNodeID: netAddr.ID,
ListenAddr: netAddr.DialString(),
},
metrics: NopMetrics(),
}
p.SetLogger(log.TestingLogger().With("peer", addr))
return p
@ -166,7 +160,7 @@ func MakeSwitch(
nodeKey := GenNodeKey()
nodeInfo := testNodeInfo(nodeKey.ID, fmt.Sprintf("node%d", i))
addr, err := NewNetAddressString(
IDAddressString(nodeKey.ID, nodeInfo.(DefaultNodeInfo).ListenAddr),
IDAddressString(nodeKey.ID, nodeInfo.ListenAddr),
)
if err != nil {
panic(err)
@ -184,7 +178,7 @@ func MakeSwitch(
sw.SetLogger(log.TestingLogger().With("switch", i))
sw.SetNodeKey(nodeKey)
ni := nodeInfo.(DefaultNodeInfo)
ni := nodeInfo
ni.Channels = []byte{}
for ch := range sw.reactorsByCh {
ni.Channels = append(ni.Channels, ch)
@ -193,7 +187,7 @@ func MakeSwitch(
// TODO: We need to setup reactors ahead of time so the NodeInfo is properly
// populated and we don't have to do those awkward overrides and setters.
t.nodeInfo = nodeInfo.(DefaultNodeInfo)
t.nodeInfo = nodeInfo
sw.SetNodeInfo(nodeInfo)
return sw
@ -228,7 +222,7 @@ func testNodeInfo(id ID, name string) NodeInfo {
}
func testNodeInfoWithNetwork(id ID, name, network string) NodeInfo {
return DefaultNodeInfo{
return NodeInfo{
ProtocolVersion: defaultProtocolVersion,
DefaultNodeID: id,
ListenAddr: fmt.Sprintf("127.0.0.1:%d", getFreePort()),
@ -236,7 +230,7 @@ func testNodeInfoWithNetwork(id ID, name, network string) NodeInfo {
Version: "1.2.3-rc0-deadbeef",
Channels: []byte{testCh},
Moniker: name,
Other: DefaultNodeInfoOther{
Other: NodeInfoOther{
TxIndex: "on",
RPCAddress: fmt.Sprintf("127.0.0.1:%d", getFreePort()),
},


+ 1
- 1
p2p/transport.go View File

@ -143,7 +143,7 @@ type Connection interface {
PubKey() crypto.PubKey
// NodeInfo returns the remote peer's node info.
NodeInfo() DefaultNodeInfo
NodeInfo() NodeInfo
// Close closes the connection.
Close() error


+ 9
- 9
p2p/transport_mconn.go View File

@ -73,7 +73,7 @@ var ConnDuplicateIPFilter ConnFilterFunc = func(cs ConnSet, c net.Conn, ips []ne
// moved out of the transport once the rest of the P2P stack is rewritten.
type MConnTransport struct {
privKey crypto.PrivKey
nodeInfo DefaultNodeInfo
nodeInfo NodeInfo
channelDescs []*ChannelDescriptor
mConnConfig conn.MConnConfig
@ -99,14 +99,14 @@ type MConnTransport struct {
// NewMConnTransport sets up a new MConn transport.
func NewMConnTransport(
logger log.Logger,
nodeInfo NodeInfo, // FIXME: should use DefaultNodeInfo, left for code compatibility
nodeInfo NodeInfo,
privKey crypto.PrivKey,
mConnConfig conn.MConnConfig,
opts ...MConnTransportOption,
) *MConnTransport {
m := &MConnTransport{
privKey: privKey,
nodeInfo: nodeInfo.(DefaultNodeInfo),
nodeInfo: nodeInfo,
mConnConfig: mConnConfig,
channelDescs: []*ChannelDescriptor{},
@ -377,7 +377,7 @@ type mConnConnection struct {
secretConn *conn.SecretConnection
mConn *conn.MConnection
peerInfo DefaultNodeInfo
peerInfo NodeInfo
closeOnce sync.Once
chReceive chan mConnMessage
@ -525,8 +525,8 @@ func newMConnConnection(
}
// handshake performs an MConn handshake, returning the peer's node info.
func (c *mConnConnection) handshake() (DefaultNodeInfo, error) {
var pbNodeInfo p2pproto.DefaultNodeInfo
func (c *mConnConnection) handshake() (NodeInfo, error) {
var pbNodeInfo p2pproto.NodeInfo
chErr := make(chan error, 2)
go func() {
_, err := protoio.NewDelimitedWriter(c.secretConn).WriteMsg(c.transport.nodeInfo.ToProto())
@ -537,11 +537,11 @@ func (c *mConnConnection) handshake() (DefaultNodeInfo, error) {
}()
for i := 0; i < cap(chErr); i++ {
if err := <-chErr; err != nil {
return DefaultNodeInfo{}, err
return NodeInfo{}, err
}
}
return DefaultNodeInfoFromProto(&pbNodeInfo)
return NodeInfoFromProto(&pbNodeInfo)
}
// onReceive is a callback for MConnection received messages.
@ -609,7 +609,7 @@ func (c *mConnConnection) ReceiveMessage() (byte, []byte, error) {
}
// NodeInfo implements Connection.
func (c *mConnConnection) NodeInfo() DefaultNodeInfo {
func (c *mConnConnection) NodeInfo() NodeInfo {
return c.peerInfo
}


+ 94
- 94
proto/tendermint/p2p/types.pb.go View File

@ -143,29 +143,29 @@ func (m *ProtocolVersion) GetApp() uint64 {
return 0
}
type DefaultNodeInfo struct {
ProtocolVersion ProtocolVersion `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version"`
DefaultNodeID string `protobuf:"bytes,2,opt,name=default_node_id,json=defaultNodeId,proto3" json:"default_node_id,omitempty"`
ListenAddr string `protobuf:"bytes,3,opt,name=listen_addr,json=listenAddr,proto3" json:"listen_addr,omitempty"`
Network string `protobuf:"bytes,4,opt,name=network,proto3" json:"network,omitempty"`
Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`
Channels []byte `protobuf:"bytes,6,opt,name=channels,proto3" json:"channels,omitempty"`
Moniker string `protobuf:"bytes,7,opt,name=moniker,proto3" json:"moniker,omitempty"`
Other DefaultNodeInfoOther `protobuf:"bytes,8,opt,name=other,proto3" json:"other"`
type NodeInfo struct {
ProtocolVersion ProtocolVersion `protobuf:"bytes,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version"`
DefaultNodeID string `protobuf:"bytes,2,opt,name=default_node_id,json=defaultNodeId,proto3" json:"default_node_id,omitempty"`
ListenAddr string `protobuf:"bytes,3,opt,name=listen_addr,json=listenAddr,proto3" json:"listen_addr,omitempty"`
Network string `protobuf:"bytes,4,opt,name=network,proto3" json:"network,omitempty"`
Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`
Channels []byte `protobuf:"bytes,6,opt,name=channels,proto3" json:"channels,omitempty"`
Moniker string `protobuf:"bytes,7,opt,name=moniker,proto3" json:"moniker,omitempty"`
Other NodeInfoOther `protobuf:"bytes,8,opt,name=other,proto3" json:"other"`
}
func (m *DefaultNodeInfo) Reset() { *m = DefaultNodeInfo{} }
func (m *DefaultNodeInfo) String() string { return proto.CompactTextString(m) }
func (*DefaultNodeInfo) ProtoMessage() {}
func (*DefaultNodeInfo) Descriptor() ([]byte, []int) {
func (m *NodeInfo) Reset() { *m = NodeInfo{} }
func (m *NodeInfo) String() string { return proto.CompactTextString(m) }
func (*NodeInfo) ProtoMessage() {}
func (*NodeInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_c8a29e659aeca578, []int{2}
}
func (m *DefaultNodeInfo) XXX_Unmarshal(b []byte) error {
func (m *NodeInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *DefaultNodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (m *NodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_DefaultNodeInfo.Marshal(b, m, deterministic)
return xxx_messageInfo_NodeInfo.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@ -175,91 +175,91 @@ func (m *DefaultNodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, err
return b[:n], nil
}
}
func (m *DefaultNodeInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_DefaultNodeInfo.Merge(m, src)
func (m *NodeInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_NodeInfo.Merge(m, src)
}
func (m *DefaultNodeInfo) XXX_Size() int {
func (m *NodeInfo) XXX_Size() int {
return m.Size()
}
func (m *DefaultNodeInfo) XXX_DiscardUnknown() {
xxx_messageInfo_DefaultNodeInfo.DiscardUnknown(m)
func (m *NodeInfo) XXX_DiscardUnknown() {
xxx_messageInfo_NodeInfo.DiscardUnknown(m)
}
var xxx_messageInfo_DefaultNodeInfo proto.InternalMessageInfo
var xxx_messageInfo_NodeInfo proto.InternalMessageInfo
func (m *DefaultNodeInfo) GetProtocolVersion() ProtocolVersion {
func (m *NodeInfo) GetProtocolVersion() ProtocolVersion {
if m != nil {
return m.ProtocolVersion
}
return ProtocolVersion{}
}
func (m *DefaultNodeInfo) GetDefaultNodeID() string {
func (m *NodeInfo) GetDefaultNodeID() string {
if m != nil {
return m.DefaultNodeID
}
return ""
}
func (m *DefaultNodeInfo) GetListenAddr() string {
func (m *NodeInfo) GetListenAddr() string {
if m != nil {
return m.ListenAddr
}
return ""
}
func (m *DefaultNodeInfo) GetNetwork() string {
func (m *NodeInfo) GetNetwork() string {
if m != nil {
return m.Network
}
return ""
}
func (m *DefaultNodeInfo) GetVersion() string {
func (m *NodeInfo) GetVersion() string {
if m != nil {
return m.Version
}
return ""
}
func (m *DefaultNodeInfo) GetChannels() []byte {
func (m *NodeInfo) GetChannels() []byte {
if m != nil {
return m.Channels
}
return nil
}
func (m *DefaultNodeInfo) GetMoniker() string {
func (m *NodeInfo) GetMoniker() string {
if m != nil {
return m.Moniker
}
return ""
}
func (m *DefaultNodeInfo) GetOther() DefaultNodeInfoOther {
func (m *NodeInfo) GetOther() NodeInfoOther {
if m != nil {
return m.Other
}
return DefaultNodeInfoOther{}
return NodeInfoOther{}
}
type DefaultNodeInfoOther struct {
type NodeInfoOther struct {
TxIndex string `protobuf:"bytes,1,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"`
RPCAddress string `protobuf:"bytes,2,opt,name=rpc_address,json=rpcAddress,proto3" json:"rpc_address,omitempty"`
}
func (m *DefaultNodeInfoOther) Reset() { *m = DefaultNodeInfoOther{} }
func (m *DefaultNodeInfoOther) String() string { return proto.CompactTextString(m) }
func (*DefaultNodeInfoOther) ProtoMessage() {}
func (*DefaultNodeInfoOther) Descriptor() ([]byte, []int) {
func (m *NodeInfoOther) Reset() { *m = NodeInfoOther{} }
func (m *NodeInfoOther) String() string { return proto.CompactTextString(m) }
func (*NodeInfoOther) ProtoMessage() {}
func (*NodeInfoOther) Descriptor() ([]byte, []int) {
return fileDescriptor_c8a29e659aeca578, []int{3}
}
func (m *DefaultNodeInfoOther) XXX_Unmarshal(b []byte) error {
func (m *NodeInfoOther) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *DefaultNodeInfoOther) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (m *NodeInfoOther) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_DefaultNodeInfoOther.Marshal(b, m, deterministic)
return xxx_messageInfo_NodeInfoOther.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@ -269,26 +269,26 @@ func (m *DefaultNodeInfoOther) XXX_Marshal(b []byte, deterministic bool) ([]byte
return b[:n], nil
}
}
func (m *DefaultNodeInfoOther) XXX_Merge(src proto.Message) {
xxx_messageInfo_DefaultNodeInfoOther.Merge(m, src)
func (m *NodeInfoOther) XXX_Merge(src proto.Message) {
xxx_messageInfo_NodeInfoOther.Merge(m, src)
}
func (m *DefaultNodeInfoOther) XXX_Size() int {
func (m *NodeInfoOther) XXX_Size() int {
return m.Size()
}
func (m *DefaultNodeInfoOther) XXX_DiscardUnknown() {
xxx_messageInfo_DefaultNodeInfoOther.DiscardUnknown(m)
func (m *NodeInfoOther) XXX_DiscardUnknown() {
xxx_messageInfo_NodeInfoOther.DiscardUnknown(m)
}
var xxx_messageInfo_DefaultNodeInfoOther proto.InternalMessageInfo
var xxx_messageInfo_NodeInfoOther proto.InternalMessageInfo
func (m *DefaultNodeInfoOther) GetTxIndex() string {
func (m *NodeInfoOther) GetTxIndex() string {
if m != nil {
return m.TxIndex
}
return ""
}
func (m *DefaultNodeInfoOther) GetRPCAddress() string {
func (m *NodeInfoOther) GetRPCAddress() string {
if m != nil {
return m.RPCAddress
}
@ -298,44 +298,44 @@ func (m *DefaultNodeInfoOther) GetRPCAddress() string {
func init() {
proto.RegisterType((*NetAddress)(nil), "tendermint.p2p.NetAddress")
proto.RegisterType((*ProtocolVersion)(nil), "tendermint.p2p.ProtocolVersion")
proto.RegisterType((*DefaultNodeInfo)(nil), "tendermint.p2p.DefaultNodeInfo")
proto.RegisterType((*DefaultNodeInfoOther)(nil), "tendermint.p2p.DefaultNodeInfoOther")
proto.RegisterType((*NodeInfo)(nil), "tendermint.p2p.NodeInfo")
proto.RegisterType((*NodeInfoOther)(nil), "tendermint.p2p.NodeInfoOther")
}
func init() { proto.RegisterFile("tendermint/p2p/types.proto", fileDescriptor_c8a29e659aeca578) }
var fileDescriptor_c8a29e659aeca578 = []byte{
// 479 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x3d, 0x8f, 0xda, 0x40,
0x10, 0xc5, 0xc6, 0x7c, 0xdc, 0x10, 0x8e, 0xcb, 0x0a, 0x45, 0x3e, 0x0a, 0x1b, 0xa1, 0x14, 0x54,
0x20, 0x39, 0x4a, 0x91, 0x2e, 0x21, 0x34, 0x34, 0x77, 0xd6, 0x2a, 0x4a, 0x91, 0xc6, 0x02, 0xef,
0x1e, 0xac, 0x30, 0xbb, 0xab, 0xf5, 0x5e, 0x42, 0xfe, 0x45, 0x7e, 0xd6, 0x95, 0x57, 0xa6, 0xb2,
0x22, 0x53, 0xe6, 0x4f, 0x44, 0x5e, 0xfb, 0x12, 0x1f, 0x4a, 0x37, 0x6f, 0xbe, 0xde, 0xcc, 0xd3,
0x83, 0x91, 0xa6, 0x9c, 0x50, 0x75, 0x60, 0x5c, 0xcf, 0x65, 0x20, 0xe7, 0xfa, 0xbb, 0xa4, 0xe9,
0x4c, 0x2a, 0xa1, 0x05, 0xba, 0xfc, 0x57, 0x9b, 0xc9, 0x40, 0x8e, 0x86, 0x5b, 0xb1, 0x15, 0xa6,
0x34, 0x2f, 0xa2, 0xb2, 0x6b, 0x12, 0x02, 0xdc, 0x50, 0xfd, 0x81, 0x10, 0x45, 0xd3, 0x14, 0xbd,
0x02, 0x9b, 0x11, 0xd7, 0x1a, 0x5b, 0xd3, 0x8b, 0x45, 0x3b, 0xcf, 0x7c, 0x7b, 0xb5, 0xc4, 0x36,
0x23, 0x26, 0x2f, 0x5d, 0xbb, 0x96, 0x0f, 0xb1, 0xcd, 0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b, 0x8b, 0xa9, 0x83, 0xe0, 0x6c, 0x4f, 0x95, 0xdb, 0x29, 0xa7, 0x2a, 0x88, 0xde,
0x43, 0x4b, 0xe8, 0x1d, 0x55, 0x6e, 0xd7, 0x88, 0xf1, 0xfa, 0x5c, 0x8c, 0x33, 0x1d, 0x6f, 0x8b,
0xde, 0x4a, 0x91, 0x72, 0x70, 0xb2, 0x81, 0xe1, 0xff, 0x9a, 0xd0, 0x35, 0x74, 0xf5, 0x31, 0x62,
0x9c, 0xd0, 0x63, 0xe9, 0x12, 0xdc, 0xd1, 0xc7, 0x55, 0x01, 0xd1, 0x1c, 0x7a, 0x4a, 0xc6, 0xe6,
0x79, 0x9a, 0xa6, 0x95, 0x6c, 0x97, 0x79, 0xe6, 0x03, 0x0e, 0x3f, 0x56, 0xfe, 0xc2, 0xa0, 0x64,
0x5c, 0xc5, 0x8b, 0xdb, 0x87, 0xdc, 0xb3, 0x1e, 0x73, 0xcf, 0xfa, 0x95, 0x7b, 0xd6, 0x8f, 0x93,
0xd7, 0x78, 0x3c, 0x79, 0x8d, 0x9f, 0x27, 0xaf, 0xf1, 0xe5, 0xed, 0x96, 0xe9, 0xdd, 0xfd, 0x66,
0x16, 0x8b, 0xc3, 0xbc, 0x66, 0xf0, 0xba, 0xd7, 0x8d, 0x8d, 0x9f, 0x9b, 0x7f, 0xd3, 0x36, 0xd9,
0x37, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xb3, 0x68, 0x97, 0x15, 0x03, 0x00, 0x00,
// 476 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0xc1, 0x6e, 0xda, 0x40,
0x10, 0xc5, 0xc6, 0x01, 0x32, 0x94, 0x90, 0xae, 0xa2, 0xca, 0x41, 0xaa, 0x8d, 0x38, 0x71, 0xc2,
0x92, 0xab, 0x1e, 0x72, 0x2c, 0xe5, 0xc2, 0x25,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0x47, 0x09, 0x83, 0x92, 0x49, 0x5d, 0x4f,
0x1f, 0x9e, 0x0b, 0xcf, 0x7a, 0x29, 0x3c, 0xeb, 0x4f, 0xe1, 0x59, 0x3f, 0xf7, 0x5e, 0xe3, 0x65,
0xef, 0x35, 0x7e, 0xed, 0xbd, 0xc6, 0x97, 0xf7, 0x2b, 0xa6, 0xd7, 0x4f, 0xcb, 0x49, 0x22, 0xb6,
0xc1, 0x51, 0x96, 0x8f, 0x63, 0x6d, 0x12, 0x7b, 0x9a, 0xf3, 0x65, 0xcb, 0x74, 0xdf, 0xfd, 0x0d,
0x00, 0x00, 0xff, 0xff, 0xa7, 0xfb, 0xff, 0xd7, 0x00, 0x03, 0x00, 0x00,
}
func (m *NetAddress) Marshal() (dAtA []byte, err error) {
@ -418,7 +418,7 @@ func (m *ProtocolVersion) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *DefaultNodeInfo) Marshal() (dAtA []byte, err error) {
func (m *NodeInfo) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@ -428,12 +428,12 @@ func (m *DefaultNodeInfo) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
func (m *DefaultNodeInfo) MarshalTo(dAtA []byte) (int, error) {
func (m *NodeInfo) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *DefaultNodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
func (m *NodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
@ -503,7 +503,7 @@ func (m *DefaultNodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *DefaultNodeInfoOther) Marshal() (dAtA []byte, err error) {
func (m *NodeInfoOther) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@ -513,12 +513,12 @@ func (m *DefaultNodeInfoOther) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
func (m *DefaultNodeInfoOther) MarshalTo(dAtA []byte) (int, error) {
func (m *NodeInfoOther) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *DefaultNodeInfoOther) MarshalToSizedBuffer(dAtA []byte) (int, error) {
func (m *NodeInfoOther) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
@ -589,7 +589,7 @@ func (m *ProtocolVersion) Size() (n int) {
return n
}
func (m *DefaultNodeInfo) Size() (n int) {
func (m *NodeInfo) Size() (n int) {
if m == nil {
return 0
}
@ -626,7 +626,7 @@ func (m *DefaultNodeInfo) Size() (n int) {
return n
}
func (m *DefaultNodeInfoOther) Size() (n int) {
func (m *NodeInfoOther) Size() (n int) {
if m == nil {
return 0
}
@ -895,7 +895,7 @@ func (m *ProtocolVersion) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *DefaultNodeInfo) Unmarshal(dAtA []byte) error {
func (m *NodeInfo) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@ -918,10 +918,10 @@ func (m *DefaultNodeInfo) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: DefaultNodeInfo: wiretype end group for non-group")
return fmt.Errorf("proto: NodeInfo: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DefaultNodeInfo: illegal tag %d (wire type %d)", fieldNum, wire)
return fmt.Errorf("proto: NodeInfo: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
@ -1208,7 +1208,7 @@ func (m *DefaultNodeInfo) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *DefaultNodeInfoOther) Unmarshal(dAtA []byte) error {
func (m *NodeInfoOther) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@ -1231,10 +1231,10 @@ func (m *DefaultNodeInfoOther) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: DefaultNodeInfoOther: wiretype end group for non-group")
return fmt.Errorf("proto: NodeInfoOther: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DefaultNodeInfoOther: illegal tag %d (wire type %d)", fieldNum, wire)
return fmt.Errorf("proto: NodeInfoOther: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:


+ 10
- 10
proto/tendermint/p2p/types.proto View File

@ -17,18 +17,18 @@ message ProtocolVersion {
uint64 app = 3;
}
message DefaultNodeInfo {
ProtocolVersion protocol_version = 1 [(gogoproto.nullable) = false];
string default_node_id = 2 [(gogoproto.customname) = "DefaultNodeID"];
string listen_addr = 3;
string network = 4;
string version = 5;
bytes channels = 6;
string moniker = 7;
DefaultNodeInfoOther other = 8 [(gogoproto.nullable) = false];
message NodeInfo {
ProtocolVersion protocol_version = 1 [(gogoproto.nullable) = false];
string default_node_id = 2 [(gogoproto.customname) = "DefaultNodeID"];
string listen_addr = 3;
string network = 4;
string version = 5;
bytes channels = 6;
string moniker = 7;
NodeInfoOther other = 8 [(gogoproto.nullable) = false];
}
message DefaultNodeInfoOther {
message NodeInfoOther {
string tx_index = 1;
string rpc_address = 2 [(gogoproto.customname) = "RPCAddress"];
}

+ 1
- 6
rpc/core/net.go View File

@ -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
rpc/core/status.go View File

@ -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,


+ 4
- 4
rpc/core/types/responses.go View File

@ -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"`


+ 6
- 6
rpc/core/types/responses_test.go View File

@ -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 {


+ 3
- 3
test/maverick/node/node.go View File

@ -1298,10 +1298,10 @@ func makeNodeInfo(
case "v2":
bcChannel = bcv2.BlockchainChannel
default:
return nil, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version)
return p2p.NodeInfo{}, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version)
}
nodeInfo := p2p.DefaultNodeInfo{
nodeInfo := p2p.NodeInfo{
ProtocolVersion: p2p.NewProtocolVersion(
version.P2PProtocol, // global
state.Version.Consensus.Block,
@ -1318,7 +1318,7 @@ func makeNodeInfo(
byte(statesync.SnapshotChannel), byte(statesync.ChunkChannel),
},
Moniker: config.Moniker,
Other: p2p.DefaultNodeInfoOther{
Other: p2p.NodeInfoOther{
TxIndex: txIndexerStatus,
RPCAddress: config.RPC.ListenAddress,
},


Loading…
Cancel
Save