-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.go
34 lines (28 loc) · 805 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-2021, Dijets Inc, All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"github.com/lasthyphen/DijetsNetworkBinary/codec"
"github.com/lasthyphen/DijetsNetworkBinary/codec/linearcodec"
"github.com/lasthyphen/DijetsNetworkBinary/utils/units"
"github.com/lasthyphen/DijetsNetworkBinary/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.NewCustomMaxLength(maxSliceLen)
errs := wrappers.Errs{}
errs.Add(
lc.RegisterType(&Tx{}),
c.RegisterCodec(codecVersion, lc),
)
if errs.Errored() {
panic(errs.Err)
}
}