-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.go
36 lines (30 loc) · 967 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
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"github.com/Toinounet21/avalanchego-trafficked-v1.7.4/codec"
"github.com/Toinounet21/avalanchego-trafficked-v1.7.4/codec/linearcodec"
"github.com/Toinounet21/avalanchego-trafficked-v1.7.4/codec/reflectcodec"
"github.com/Toinounet21/avalanchego-trafficked-v1.7.4/utils/units"
"github.com/Toinounet21/avalanchego-trafficked-v1.7.4/utils/wrappers"
)
const (
codecVersion uint16 = 0
maxMessageSize = 512 * units.KiB
maxSliceLen = maxMessageSize
)
// Codec does serialization and deserialization
var c codec.Manager
func init() {
c = codec.NewManager(maxMessageSize)
lc := linearcodec.New(reflectcodec.DefaultTagName, maxSliceLen)
errs := wrappers.Errs{}
errs.Add(
lc.RegisterType(&AtomicTx{}),
lc.RegisterType(&EthTxs{}),
c.RegisterCodec(codecVersion, lc),
)
if errs.Errored() {
panic(errs.Err)
}
}