forked from ava-labs/avalanchego
/
codec.go
34 lines (27 loc) · 770 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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package sync
import (
"github.com/VidarSolutions/avalanchego/codec"
"github.com/VidarSolutions/avalanchego/codec/linearcodec"
"github.com/VidarSolutions/avalanchego/utils/units"
"github.com/VidarSolutions/avalanchego/utils/wrappers"
)
const (
Version = 0 // TODO danlaine unexport this
maxMessageSize = 1 * units.MiB
)
var syncCodec codec.Manager
func init() {
syncCodec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault()
errs := wrappers.Errs{}
errs.Add(
c.RegisterType(&ChangeProofRequest{}),
c.RegisterType(&RangeProofRequest{}),
syncCodec.RegisterCodec(Version, c),
)
if errs.Errored() {
panic(errs.Err)
}
}