-
Notifications
You must be signed in to change notification settings - Fork 12
/
versions.go
146 lines (137 loc) · 4.21 KB
/
versions.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package ouroboros
const (
// The NtC protocol versions have the 15th bit set in the handshake
PROTOCOL_VERSION_NTC_FLAG = 0x8000
)
type ProtocolVersionNtC struct {
// Most of these are enabled in all of the protocol versions that we support, but
// they are here for completeness
EnableLocalQueryProtocol bool
EnableShelleyEra bool
EnableAllegraEra bool
EnableMaryEra bool
EnableAlonzoEra bool
EnableBabbageEra bool
EnableLocalTxMonitorProtocol bool
}
// We don't bother supporting NtC protocol versions before 9 (when Alonzo was enabled)
var ProtocolVersionMapNtC = map[uint16]ProtocolVersionNtC{
9: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
},
// added GetChainBlockNo and GetChainPoint queries
10: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
},
// added GetRewardInfoPools Block query
11: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
},
12: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
EnableLocalTxMonitorProtocol: true,
},
13: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
EnableBabbageEra: true,
EnableLocalTxMonitorProtocol: true,
},
// added GetPoolDistr, GetPoolState, @GetSnapshots
14: ProtocolVersionNtC{
EnableLocalQueryProtocol: true,
EnableShelleyEra: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
EnableBabbageEra: true,
EnableLocalTxMonitorProtocol: true,
},
}
type ProtocolVersionNtN struct {
// Most of these are enabled in all of the protocol versions that we support, but
// they are here for completeness
EnableShelleyEra bool
EnableKeepAliveProtocol bool
EnableAllegraEra bool
EnableMaryEra bool
EnableAlonzoEra bool
EnableBabbageEra bool
EnableFullDuplex bool
}
// We don't bother supporting NtN protocol versions before 7 (when Alonzo was enabled)
var ProtocolVersionMapNtN = map[uint16]ProtocolVersionNtN{
7: ProtocolVersionNtN{
EnableShelleyEra: true,
EnableKeepAliveProtocol: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
},
8: ProtocolVersionNtN{
EnableShelleyEra: true,
EnableKeepAliveProtocol: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
},
9: ProtocolVersionNtN{
EnableShelleyEra: true,
EnableKeepAliveProtocol: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
EnableBabbageEra: true,
},
10: ProtocolVersionNtN{
EnableShelleyEra: true,
EnableKeepAliveProtocol: true,
EnableAllegraEra: true,
EnableMaryEra: true,
EnableAlonzoEra: true,
EnableBabbageEra: true,
EnableFullDuplex: true,
},
}
func GetProtocolVersionsNtC() []uint16 {
versions := []uint16{}
for key := range ProtocolVersionMapNtC {
versions = append(versions, key+PROTOCOL_VERSION_NTC_FLAG)
}
return versions
}
func GetProtocolVersionNtC(version uint16) ProtocolVersionNtC {
if version > PROTOCOL_VERSION_NTC_FLAG {
version = version - PROTOCOL_VERSION_NTC_FLAG
}
return ProtocolVersionMapNtC[version]
}
func GetProtocolVersionsNtN() []uint16 {
versions := []uint16{}
for key := range ProtocolVersionMapNtN {
versions = append(versions, key)
}
return versions
}
func GetProtocolVersionNtN(version uint16) ProtocolVersionNtN {
return ProtocolVersionMapNtN[version]
}