1
1
package observer
2
2
3
3
import (
4
- "encoding/base64"
5
4
"fmt"
6
5
"time"
7
6
@@ -151,11 +150,11 @@ func supplementalDataFromGpbft(sd gpbft.SupplementalData) SupplementalData {
151
150
func (m Message ) ToPartialMessage () (* gpbft.PartialGMessage , error ) {
152
151
payload , err := m .Vote .ToGpbftPayload ()
153
152
if err != nil {
154
- return nil , err
153
+ return nil , fmt . Errorf ( "could not convert vote to gpbft payload: %w" , err )
155
154
}
156
155
gj , err := m .Justification .ToGpbftJustification ()
157
156
if err != nil {
158
- return nil , err
157
+ return nil , fmt . Errorf ( "could not convert justification to gpbft justification: %w" , err )
159
158
}
160
159
161
160
return & gpbft.PartialGMessage {
@@ -173,16 +172,16 @@ func (m Message) ToPartialMessage() (*gpbft.PartialGMessage, error) {
173
172
func (p Payload ) ToGpbftPayload () (gpbft.Payload , error ) {
174
173
phase , err := phaseFromString (p .Phase )
175
174
if err != nil {
176
- return gpbft.Payload {}, err
175
+ return gpbft.Payload {}, fmt . Errorf ( "could not convert phase: %w" , err )
177
176
}
178
177
sd , err := p .SupplementalData .ToGpbftSupplementalData ()
179
178
if err != nil {
180
- return gpbft.Payload {}, err
179
+ return gpbft.Payload {}, fmt . Errorf ( "could not convert supplemental data: %w" , err )
181
180
}
182
181
183
182
gv , err := ToGpbftChain (p .Value ... )
184
183
if err != nil {
185
- return gpbft.Payload {}, err
184
+ return gpbft.Payload {}, fmt . Errorf ( "could not convert value: %w" , err )
186
185
}
187
186
188
187
return gpbft.Payload {
@@ -246,20 +245,13 @@ func (j *Justification) ToGpbftJustification() (*gpbft.Justification, error) {
246
245
gsigners , _ := bitfield .NewFromIter (ri )
247
246
payload , err := j .Vote .ToGpbftPayload ()
248
247
if err != nil {
249
- return nil , err
250
- }
251
-
252
- // Embedded struct as json, hence the decode.
253
- s := string (j .Signature )
254
- decoded , err := base64 .StdEncoding .DecodeString (s )
255
- if err != nil {
256
- return nil , err
248
+ return nil , fmt .Errorf ("could not convert vote to gpbft payload: %w" , err )
257
249
}
258
250
259
251
return & gpbft.Justification {
260
252
Vote : payload ,
261
253
Signers : gsigners ,
262
- Signature : decoded ,
254
+ Signature : j . Signature ,
263
255
}, nil
264
256
}
265
257
0 commit comments