github.com/amazechain/amc@v0.1.3/internal/p2p/encoder/network_encoding.go (about)

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