github.com/pure-x-eth/consensus_tm@v0.0.0-20230502163723-e3c2ff987250/p2p/types.go (about)

     1  package p2p
     2  
     3  import (
     4  	"github.com/gogo/protobuf/proto"
     5  	"github.com/pure-x-eth/consensus_tm/p2p/conn"
     6  	tmp2p "github.com/pure-x-eth/consensus_tm/proto/tendermint/p2p"
     7  )
     8  
     9  type ChannelDescriptor = conn.ChannelDescriptor
    10  type ConnectionStatus = conn.ConnectionStatus
    11  
    12  // Envelope contains a message with sender routing info.
    13  type Envelope struct {
    14  	Src       Peer          // sender (empty if outbound)
    15  	Message   proto.Message // message payload
    16  	ChannelID byte
    17  }
    18  
    19  // Unwrapper is a Protobuf message that can contain a variety of inner messages
    20  // (e.g. via oneof fields). If a Channel's message type implements Unwrapper, the
    21  // p2p layer will automatically unwrap inbound messages so that reactors do not have to do this themselves.
    22  type Unwrapper interface {
    23  	proto.Message
    24  
    25  	// Unwrap will unwrap the inner message contained in this message.
    26  	Unwrap() (proto.Message, error)
    27  }
    28  
    29  // Wrapper is a companion type to Unwrapper. It is a Protobuf message that can contain a variety of inner messages. The p2p layer will automatically wrap outbound messages so that the reactors do not have to do it themselves.
    30  type Wrapper interface {
    31  	proto.Message
    32  
    33  	// Wrap will take the underlying message and wrap it in its wrapper type.
    34  	Wrap() proto.Message
    35  }
    36  
    37  var (
    38  	_ Wrapper = &tmp2p.PexRequest{}
    39  	_ Wrapper = &tmp2p.PexAddrs{}
    40  )