-
Notifications
You must be signed in to change notification settings - Fork 670
/
codec.go
40 lines (33 loc) · 906 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
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package keystore
import (
"math"
"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
"github.com/ava-labs/avalanchego/codec/reflectcodec"
"github.com/ava-labs/avalanchego/utils/wrappers"
)
const (
// CodecVersion is the current default codec version
CodecVersion = 0
)
// Codecs do serialization and deserialization
var (
Codec codec.Manager
LegacyCodec codec.Manager
)
func init() {
c := linearcodec.NewDefault()
Codec = codec.NewDefaultManager()
lc := linearcodec.New(reflectcodec.DefaultTagName, math.MaxUint32)
LegacyCodec = codec.NewManager(math.MaxInt32)
errs := wrappers.Errs{}
errs.Add(
Codec.RegisterCodec(CodecVersion, c),
LegacyCodec.RegisterCodec(CodecVersion, lc),
)
if errs.Errored() {
panic(errs.Err)
}
}