github.com/badrootd/nibiru-cometbft@v0.37.5-0.20240307173500-2a75559eee9b/p2p/types.go (about) 1 package p2p 2 3 import ( 4 "github.com/badrootd/nibiru-cometbft/p2p/conn" 5 cmtp2p "github.com/badrootd/nibiru-cometbft/proto/tendermint/p2p" 6 "github.com/cosmos/gogoproto/proto" 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 = &cmtp2p.PexRequest{} 39 _ Wrapper = &cmtp2p.PexAddrs{} 40 )