mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package message
|
|
|
|
import (
|
|
"github.com/luxfi/codec"
|
|
"github.com/luxfi/codec/linearcodec"
|
|
"github.com/luxfi/codec/wrappers"
|
|
"github.com/luxfi/constants"
|
|
)
|
|
|
|
const (
|
|
Version = uint16(0)
|
|
maxMessageSize = 2*constants.MiB - 64*constants.KiB // Subtract 64 KiB from p2p network cap to leave room for encoding overhead from Luxd
|
|
)
|
|
|
|
var Codec codec.Manager
|
|
|
|
func init() {
|
|
Codec = codec.NewManager(maxMessageSize)
|
|
c := linearcodec.NewDefault()
|
|
|
|
errs := wrappers.Errs{}
|
|
// Gossip types and sync summary type removed from codec
|
|
c.SkipRegistrations(3)
|
|
errs.Add(
|
|
// state sync types
|
|
c.RegisterType(BlockRequest{}),
|
|
c.RegisterType(BlockResponse{}),
|
|
c.RegisterType(LeafsRequest{}),
|
|
c.RegisterType(LeafsResponse{}),
|
|
c.RegisterType(CodeRequest{}),
|
|
c.RegisterType(CodeResponse{}),
|
|
)
|
|
|
|
// Deprecated Warp request/responde types are skipped
|
|
// See https://github.com/luxfi/coreth/pull/999
|
|
c.SkipRegistrations(3)
|
|
|
|
Codec.RegisterCodec(Version, c)
|
|
|
|
if errs.Errored() {
|
|
panic(errs.Err)
|
|
}
|
|
}
|