prysm-pulse/beacon-chain/p2p/encoder/network_encoding.go

24 lines
690 B
Go
Raw Normal View History

package encoder
import (
"io"
"github.com/gogo/protobuf/proto"
)
// Defines the different encoding formats
const (
SSZ = "ssz" // SSZ is SSZ only.
SSZSnappy = "ssz-snappy" // SSZSnappy is SSZ with snappy compression.
)
// NetworkEncoding represents an encoder compatible with Ethereum 2.0 p2p.
type NetworkEncoding interface {
// Decode reads bytes from the reader and decodes it to the provided message.
Decode(io.Reader, proto.Message) error
// Encode an arbitrary message to the provided writer.
Encode(io.Writer, proto.Message) (int, error)
// ProtocolSuffix returns the last part of the protocol ID to indicate the encoding scheme.
ProtocolSuffix() string
}