github.com/Finschia/ostracon@v1.1.5/p2p/types.go (about)

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