forked from ava-labs/coreth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec.go
66 lines (52 loc) · 1.37 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// (c) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"github.com/MetalBlockchain/metalgo/codec"
"github.com/MetalBlockchain/metalgo/codec/linearcodec"
"github.com/MetalBlockchain/metalgo/utils/units"
"github.com/MetalBlockchain/metalgo/utils/wrappers"
)
const (
Version = uint16(0)
maxMessageSize = 1 * units.MiB
)
var (
Codec codec.Manager
CrossChainCodec codec.Manager
)
func init() {
Codec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault()
errs := wrappers.Errs{}
errs.Add(
// Gossip types
c.RegisterType(AtomicTxGossip{}),
c.RegisterType(EthTxsGossip{}),
// Types for state sync frontier consensus
c.RegisterType(SyncSummary{}),
// state sync types
c.RegisterType(BlockRequest{}),
c.RegisterType(BlockResponse{}),
c.RegisterType(LeafsRequest{}),
c.RegisterType(LeafsResponse{}),
c.RegisterType(CodeRequest{}),
c.RegisterType(CodeResponse{}),
Codec.RegisterCodec(Version, c),
)
if errs.Errored() {
panic(errs.Err)
}
CrossChainCodec = codec.NewManager(maxMessageSize)
ccc := linearcodec.NewDefault()
errs = wrappers.Errs{}
errs.Add(
// CrossChainRequest Types
ccc.RegisterType(EthCallRequest{}),
ccc.RegisterType(EthCallResponse{}),
CrossChainCodec.RegisterCodec(Version, ccc),
)
if errs.Errored() {
panic(errs.Err)
}
}