-
Notifications
You must be signed in to change notification settings - Fork 213
/
codec.go
45 lines (36 loc) · 979 Bytes
/
codec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// (c) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
const (
Version = uint16(0)
maxMessageSize = 1 * units.MiB
)
var Codec codec.Manager
func init() {
Codec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault()
errs := wrappers.Errs{}
errs.Add(
// Gossip types
c.RegisterType(TxsGossip{}),
// Types for state sync frontier consensus
c.RegisterType(SyncSummary{}),
// state sync types
c.RegisterType(BlockRequest{}),
c.RegisterType(BlockResponse{}),
c.RegisterType(LeafsRequest{}),
c.RegisterType(LeafsResponse{}),
c.RegisterType(CodeRequest{}),
c.RegisterType(CodeResponse{}),
Codec.RegisterCodec(Version, c),
)
if errs.Errored() {
panic(errs.Err)
}
}