Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

contract, swap: refactor backend to commit on sendTransaction #2092

Merged
merged 13 commits into from
Feb 12, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
swap/chain: check err first in WaitMined
  • Loading branch information
ralph-pichler committed Feb 11, 2020
commit d3ff20b0f3f9bc836765c4e1f453907e041fc98b
14 changes: 5 additions & 9 deletions swap/chain/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,19 @@ func WaitMined(ctx context.Context, b Backend, hash common.Hash) (*types.Receipt
queryTicker := time.NewTicker(time.Second)
defer queryTicker.Stop()

if ctx == nil {
ctx = context.Background()
}

for {
receipt, err := b.TransactionReceipt(ctx, hash)
if err != nil {
log.Trace("Receipt retrieval failed", "err", err)
acud marked this conversation as resolved.
Show resolved Hide resolved
}
if receipt != nil {
if receipt.Status != types.ReceiptStatusSuccessful {
return nil, ErrTransactionReverted
}
return receipt, nil
}
if err != nil {
log.Trace("Receipt retrieval failed", "err", err)
} else {
log.Trace("Transaction not yet mined")
}

log.Trace("Transaction not yet mined")
ralph-pichler marked this conversation as resolved.
Show resolved Hide resolved
// Wait for the next round.
select {
case <-ctx.Done():
ralph-pichler marked this conversation as resolved.
Show resolved Hide resolved
Expand Down