forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 3
/
codec.go
36 lines (29 loc) · 938 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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package vertex
import (
"github.com/MetalBlockchain/metalgo/codec"
"github.com/MetalBlockchain/metalgo/codec/linearcodec"
"github.com/MetalBlockchain/metalgo/codec/reflectcodec"
"github.com/MetalBlockchain/metalgo/utils"
"github.com/MetalBlockchain/metalgo/utils/units"
)
const (
CodecVersion uint16 = 0
CodecVersionWithStopVtx uint16 = 1
// maxSize is the maximum allowed vertex size. It is necessary to deter DoS
maxSize = units.MiB
)
var Codec codec.Manager
func init() {
lc0 := linearcodec.New([]string{reflectcodec.DefaultTagName + "V0"})
lc1 := linearcodec.New([]string{reflectcodec.DefaultTagName + "V1"})
Codec = codec.NewManager(maxSize)
err := utils.Err(
Codec.RegisterCodec(CodecVersion, lc0),
Codec.RegisterCodec(CodecVersionWithStopVtx, lc1),
)
if err != nil {
panic(err)
}
}