@@ -454,7 +454,7 @@ func (h *election) Elections(w http.ResponseWriter, r *http.Request) {
454
454
}
455
455
456
456
// waitForTxnID blocks until `ID` is included or `events` is closed.
457
- func (h * election ) waitForTxnID (events <- chan ordering.Event , ID []byte ) bool {
457
+ func (h * election ) waitForTxnID (events <- chan ordering.Event , ID []byte ) error {
458
458
for event := range events {
459
459
for _ , res := range event .Transactions {
460
460
if ! bytes .Equal (res .GetTransaction ().GetID (), ID ) {
@@ -463,12 +463,14 @@ func (h *election) waitForTxnID(events <-chan ordering.Event, ID []byte) bool {
463
463
464
464
ok , msg := res .GetStatus ()
465
465
if ! ok {
466
- h . logger . Info (). Msgf ("transaction %x denied : %s" , ID , msg )
466
+ return xerrors . Errorf ("transaction %x denied : %s" , ID , msg )
467
467
}
468
- return ok
468
+
469
+ return nil
469
470
}
470
471
}
471
- return false
472
+
473
+ return xerrors .New ("transaction not found" )
472
474
}
473
475
474
476
func (h * election ) getElectionsMetadata () (types.ElectionsMetadata , error ) {
@@ -552,9 +554,9 @@ func (h *election) submitAndWaitForTxn(ctx context.Context, cmd evoting.Command,
552
554
return nil , xerrors .Errorf ("failed to add transaction to the pool: %v" , err )
553
555
}
554
556
555
- ok : = h .waitForTxnID (events , tx .GetID ())
556
- if ! ok {
557
- return nil , xerrors .Errorf ("transaction not processed within timeout" )
557
+ err = h .waitForTxnID (events , tx .GetID ())
558
+ if err != nil {
559
+ return nil , xerrors .Errorf ("failed to wait for transaction: %v" , err )
558
560
}
559
561
560
562
return tx .GetID (), nil
0 commit comments