Documentation
¶
Index ¶
- Constants
- Variables
- func NewDefault() codec.Codec
- func NewManager(maxSize int) codec.Manager
- type LinearCodec
- type Manager
- func (m *Manager) Marshal(version uint16, source interface{}) ([]byte, error)
- func (m *Manager) RegisterCodec(version uint16, codec codec.Codec) error
- func (m *Manager) Size(version uint16, source interface{}) (int, error)
- func (m *Manager) Unmarshal(source []byte, destination interface{}) (uint16, error)
Constants ¶
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.
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 ¶
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 ¶
func NewManager ¶
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 ¶
type LinearCodec ¶
type LinearCodec struct{}
LinearCodec is a simple codec implementation
func (*LinearCodec) MarshalInto ¶
func (c *LinearCodec) MarshalInto(source interface{}, destination []byte) error
MarshalInto marshals the source into the destination buffer
func (*LinearCodec) Size ¶
func (c *LinearCodec) Size(value interface{}) (int, error)
Size returns the encoded size of the value
func (*LinearCodec) Unmarshal ¶
func (c *LinearCodec) Unmarshal(source []byte, destination interface{}) error
Unmarshal unmarshals from source into destination
type 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.
func (*Manager) RegisterCodec ¶
RegisterCodec registers a codec for a version