github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/p2p/encoder/network_encoding.go (about)

     1  package encoder
     2  
     3  import (
     4  	"io"
     5  )
     6  
     7  // NetworkEncoding represents an encoder compatible with Ethereum consensus p2p.
     8  type NetworkEncoding interface {
     9  	// DecodeGossip to the provided gossip message. The interface must be a pointer to the decoding destination.
    10  	DecodeGossip([]byte, interface{}) error
    11  	// DecodeWithMaxLength a bytes from a reader with a varint length prefix. The interface must be a pointer to the
    12  	// decoding destination. The length of the message should not be more than the provided limit.
    13  	DecodeWithMaxLength(io.Reader, interface{}) error
    14  	// EncodeGossip an arbitrary gossip message to the provided writer. The interface must be a pointer object to encode.
    15  	EncodeGossip(io.Writer, interface{}) (int, error)
    16  	// EncodeWithMaxLength an arbitrary message to the provided writer with a varint length prefix. The interface must be
    17  	// a pointer object to encode. The encoded message should not be bigger than the provided limit.
    18  	EncodeWithMaxLength(io.Writer, interface{}) (int, error)
    19  	// ProtocolSuffix returns the last part of the protocol ID to indicate the encoding scheme.
    20  	ProtocolSuffix() string
    21  }