linear
v1.21.5
Documentation
pkg.go.dev ↗Constants
DefaultMaxBlobSize
const DefaultMaxBlobSize = 256 * 1024 * 1024
DefaultMaxBlobSize is the default per-blob ceiling enforced by Manager. It is sized to comfortably hold:
- FHE bootstrap keys for STD128 / PN10QP27 / PN11QP54 parameters (~50MB)
- State sync chunks and large Verkle proofs
- 4x headroom on top of the largest known caller
256MiB is a soft cap; callers may pass a larger value to NewManager. The hard cap remains MaxInt (math.MaxInt32 = ~2GiB) due to the on-disk length prefix being uint32.
MaxInt
const MaxInt = math.MaxInt32
MaxInt is the absolute upper bound on a slice length encoded by this codec. Slice lengths are written as a uint32, so the encoded length cannot exceed math.MaxInt32 without overflowing on 32-bit platforms during decode.
Variables
ErrUnknownVersion (7 declarations)
var (
ErrUnknownVersion = errors.New("unknown codec version")
ErrMarshalNil = errors.New("can't marshal nil")
ErrUnmarshalNil = errors.New("can't unmarshal nil")
ErrUnexpectedType = errors.New("unexpected type")
ErrDoesNotImplement = errors.New("type does not implement interface")
ErrUnexportedField = errors.New("unexported field")
ErrMaxSliceLenExceeded = errors.New("max slice length exceeded")
)
Functions
NewDefault
func NewDefault() codec.Codec
NewDefault creates a new linear codec
NewManager
func NewManager(maxSize int) codec.Manager
NewManager creates a new codec manager. maxSize is the per-blob ceiling in bytes; pass 0 (or any non-positive value) to use DefaultMaxBlobSize. Values above MaxInt are clamped to MaxInt.
Types
LinearCodec
type LinearCodec struct{}
LinearCodec is a simple codec implementation
LinearCodec.MarshalInto
func (c *LinearCodec) MarshalInto(source interface{}, destination []byte) error
MarshalInto marshals the source into the destination buffer
LinearCodec.Size
func (c *LinearCodec) Size(value interface{}) (int, error)
Size returns the encoded size of the value
LinearCodec.Unmarshal
func (c *LinearCodec) Unmarshal(source []byte, destination interface{}) error
Unmarshal unmarshals from source into destination
Manager
type Manager struct {
// contains filtered or unexported fields
}
Manager implements codec.Manager.
maxBlobSize bounds the largest single value the Manager will accept on Marshal and the largest single value it will return on Unmarshal. Set via NewManager. A value <= 0 means "use DefaultMaxBlobSize". The ceiling is MaxInt; values above MaxInt are clamped.
Manager.Marshal
func (m *Manager) Marshal(version uint16, source interface{}) ([]byte, error)
Marshal encodes the source object
Manager.RegisterCodec
func (m *Manager) RegisterCodec(version uint16, codec codec.Codec) error
RegisterCodec registers a codec for a version
Manager.Size
func (m *Manager) Size(version uint16, source interface{}) (int, error)
Size returns the encoded size of the object
Manager.Unmarshal
func (m *Manager) Unmarshal(source []byte, destination interface{}) (uint16, error)
Unmarshal decodes into the destination object