Documentation ¶
Overview ¶
Package msg contains all message types, as well as serialising and deserialising logic used in peer communications.
Index ¶
- func Encode(msg Msg, w io.Writer) (err error)
- func RegisterDecoder(t Type, decoder func(io.Reader) (Msg, error))
- func RegisterExternalDecoder(t Type, decoder func(io.Reader) (Msg, error), name string)
- func TestMsg(t *testing.T, msg Msg)
- type Cache
- type Cacher
- type Msg
- type PingMsg
- type PongMsg
- type Predicate
- type Type
- type WithAnnex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDecoder ¶
RegisterDecoder sets the decoder of messages of Type `t`.
func RegisterExternalDecoder ¶
RegisterExternalDecoder sets the decoder of messages of external type `t`. This is like RegisterDecoder but for message types not part of the Perun wire protocol and thus not known natively. This can be used by users of the framework to create additional message types and send them over the same peer connection. It also comes in handy to register types for testing.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a message cache. The default value is a valid empty cache.
func (*Cache) Flush ¶
func (c *Cache) Flush()
Flush empties the message cache and removes all predicates.
func (*Cache) Get ¶
Get retrieves all messages from the cache that match the predicate. They are removed from the Cache.
type Cacher ¶
type Cacher interface { // Cache should enable the caching of messages Cache(context.Context, Predicate) }
A Cacher has the Cache method to enable caching of messages.
type Msg ¶
type Msg interface { // Type returns the message's type. Type() Type // encoding of payload. Type byte should not be encoded. perunio.Encoder }
Msg is the top-level abstraction for all messages sent between perun nodes.
type PingMsg ¶
type PingMsg struct {
// contains filtered or unexported fields
}
PingMsg is a ping request. It contains the time at which it was sent, so that the recipient can also measure the time it took to transmit the ping request.
type PongMsg ¶
type PongMsg struct {
// contains filtered or unexported fields
}
PongMsg is the response to a ping message. It contains the time at which it was sent, so that the recipient knows how long the ping request took to be transmitted, and how quickly the response was sent.
type Type ¶
type Type uint8
Type is an enumeration used for (de)serializing messages and identifying a message's Type.
const ( Ping Type = iota Pong AuthResponse ChannelProposal ChannelProposalAcc ChannelProposalRej ChannelUpdate ChannelUpdateAcc ChannelUpdateRej LastType // upper bound on the message types of the Perun wire protocol )
Enumeration of message categories known to the Perun framework.