@@ -7,16 +7,24 @@ import (
7
7
"github.com/renproject/surge"
8
8
)
9
9
10
+ type MessageType int8
11
+
12
+ const (
13
+ MessageTypePropose MessageType = 1
14
+ MessageTypePrevote MessageType = 2
15
+ MessageTypePrecommit MessageType = 3
16
+ )
17
+
10
18
// A Propose message is sent by the proposer Process at most once per Round. The
11
19
// Scheduler interfaces determines which Process is the proposer at any given
12
20
// Height and Round.
13
21
type Propose struct {
14
- Height Height `json:"height"`
15
- Round Round `json:"round"`
16
- ValidRound Round `json:"validRound"`
17
- Value Value `json:"value"`
18
- From id. Signatory `json:"from"`
19
- Signature id.Signature `json:"signature "`
22
+ Height Height `json:"height"`
23
+ Round Round `json:"round"`
24
+ ValidRound Round `json:"validRound"`
25
+ Value Value `json:"value"`
26
+
27
+ From id.Signatory `json:"from "`
20
28
}
21
29
22
30
// NewProposeHash receives fields of a propose message and hashes the message
@@ -65,8 +73,7 @@ func (propose Propose) SizeHint() int {
65
73
surge .SizeHint (propose .Round ) +
66
74
surge .SizeHint (propose .ValidRound ) +
67
75
surge .SizeHint (propose .Value ) +
68
- surge .SizeHint (propose .From ) +
69
- surge .SizeHint (propose .Signature )
76
+ surge .SizeHint (propose .From )
70
77
}
71
78
72
79
// Marshal this message into binary.
@@ -91,10 +98,6 @@ func (propose Propose) Marshal(buf []byte, rem int) ([]byte, int, error) {
91
98
if err != nil {
92
99
return buf , rem , fmt .Errorf ("marshaling from=%v: %v" , propose .From , err )
93
100
}
94
- buf , rem , err = surge .Marshal (propose .Signature , buf , rem )
95
- if err != nil {
96
- return buf , rem , fmt .Errorf ("marshaling signature=%v: %v" , propose .Signature , err )
97
- }
98
101
return buf , rem , nil
99
102
}
100
103
@@ -120,10 +123,6 @@ func (propose *Propose) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
120
123
if err != nil {
121
124
return buf , rem , fmt .Errorf ("unmarshaling from: %v" , err )
122
125
}
123
- buf , rem , err = surge .Unmarshal (& propose .Signature , buf , rem )
124
- if err != nil {
125
- return buf , rem , fmt .Errorf ("unmarshaling signature: %v" , err )
126
- }
127
126
return buf , rem , nil
128
127
}
129
128
@@ -133,11 +132,11 @@ func (propose *Propose) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
133
132
// there are many other conditions which can cause a Process to Prevote. See the
134
133
// Process for more information.
135
134
type Prevote struct {
136
- Height Height `json:"height"`
137
- Round Round `json:"round"`
138
- Value Value `json:"value"`
139
- From id. Signatory `json:"from"`
140
- Signature id.Signature `json:"signature "`
135
+ Height Height `json:"height"`
136
+ Round Round `json:"round"`
137
+ Value Value `json:"value"`
138
+
139
+ From id.Signatory `json:"from "`
141
140
}
142
141
143
142
// NewPrevoteHash receives fields of a prevote message and hashes the message
@@ -180,8 +179,7 @@ func (prevote Prevote) SizeHint() int {
180
179
return surge .SizeHint (prevote .Height ) +
181
180
surge .SizeHint (prevote .Round ) +
182
181
surge .SizeHint (prevote .Value ) +
183
- surge .SizeHint (prevote .From ) +
184
- surge .SizeHint (prevote .Signature )
182
+ surge .SizeHint (prevote .From )
185
183
}
186
184
187
185
// Marshal this message into binary.
@@ -202,10 +200,6 @@ func (prevote Prevote) Marshal(buf []byte, rem int) ([]byte, int, error) {
202
200
if err != nil {
203
201
return buf , rem , fmt .Errorf ("marshaling from=%v: %v" , prevote .From , err )
204
202
}
205
- buf , rem , err = surge .Marshal (prevote .Signature , buf , rem )
206
- if err != nil {
207
- return buf , rem , fmt .Errorf ("marshaling signature=%v: %v" , prevote .Signature , err )
208
- }
209
203
return buf , rem , nil
210
204
}
211
205
@@ -227,10 +221,6 @@ func (prevote *Prevote) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
227
221
if err != nil {
228
222
return buf , rem , fmt .Errorf ("unmarshaling from: %v" , err )
229
223
}
230
- buf , rem , err = surge .Unmarshal (& prevote .Signature , buf , rem )
231
- if err != nil {
232
- return buf , rem , fmt .Errorf ("unmarshaling signature: %v" , err )
233
- }
234
224
return buf , rem , nil
235
225
}
236
226
@@ -240,11 +230,11 @@ func (prevote *Prevote) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
240
230
// progress to the next Height. However, there are many other conditions which
241
231
// can cause a Process to Precommit. See the Process for more information.
242
232
type Precommit struct {
243
- Height Height `json:"height"`
244
- Round Round `json:"round"`
245
- Value Value `json:"value"`
246
- From id. Signatory `json:"from"`
247
- Signature id.Signature `json:"signature "`
233
+ Height Height `json:"height"`
234
+ Round Round `json:"round"`
235
+ Value Value `json:"value"`
236
+
237
+ From id.Signatory `json:"from "`
248
238
}
249
239
250
240
// NewPrecommitHash receives fields of a precommit message and hashes the message
@@ -287,8 +277,7 @@ func (precommit Precommit) SizeHint() int {
287
277
return surge .SizeHint (precommit .Height ) +
288
278
surge .SizeHint (precommit .Round ) +
289
279
surge .SizeHint (precommit .Value ) +
290
- surge .SizeHint (precommit .From ) +
291
- surge .SizeHint (precommit .Signature )
280
+ surge .SizeHint (precommit .From )
292
281
}
293
282
294
283
// Marshal this message into binary.
@@ -309,10 +298,6 @@ func (precommit Precommit) Marshal(buf []byte, rem int) ([]byte, int, error) {
309
298
if err != nil {
310
299
return buf , rem , fmt .Errorf ("marshaling from=%v: %v" , precommit .From , err )
311
300
}
312
- buf , rem , err = surge .Marshal (precommit .Signature , buf , rem )
313
- if err != nil {
314
- return buf , rem , fmt .Errorf ("marshaling signature=%v: %v" , precommit .Signature , err )
315
- }
316
301
return buf , rem , nil
317
302
}
318
303
@@ -334,9 +319,5 @@ func (precommit *Precommit) Unmarshal(buf []byte, rem int) ([]byte, int, error)
334
319
if err != nil {
335
320
return buf , rem , fmt .Errorf ("unmarshaling from: %v" , err )
336
321
}
337
- buf , rem , err = surge .Unmarshal (& precommit .Signature , buf , rem )
338
- if err != nil {
339
- return buf , rem , fmt .Errorf ("unmarshaling signature: %v" , err )
340
- }
341
322
return buf , rem , nil
342
323
}
0 commit comments