Skip to content

Commit afe344b

Browse files
authored
accounts/abi/bind: improve WaitMined error handling (#24321)
This change makes it so WaitMined no longer logs an error when the receipt is unavailable. It also changes the simulated backend to return NotFound for unavailable receipts, just like ethclient does.
1 parent c5436c8 commit afe344b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common
230230
defer b.mu.Unlock()
231231

232232
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash, b.config)
233+
if receipt == nil {
234+
return nil, ethereum.NotFound
235+
}
233236
return receipt, nil
234237
}
235238

accounts/abi/bind/util.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"time"
2323

24+
"github.com/ethereum/go-ethereum"
2425
"github.com/ethereum/go-ethereum/common"
2526
"github.com/ethereum/go-ethereum/core/types"
2627
"github.com/ethereum/go-ethereum/log"
@@ -35,14 +36,16 @@ func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*ty
3536
logger := log.New("hash", tx.Hash())
3637
for {
3738
receipt, err := b.TransactionReceipt(ctx, tx.Hash())
38-
if receipt != nil {
39+
if err == nil {
3940
return receipt, nil
4041
}
41-
if err != nil {
42-
logger.Trace("Receipt retrieval failed", "err", err)
43-
} else {
42+
43+
if errors.Is(err, ethereum.NotFound) {
4444
logger.Trace("Transaction not yet mined")
45+
} else {
46+
logger.Trace("Receipt retrieval failed", "err", err)
4547
}
48+
4649
// Wait for the next round.
4750
select {
4851
case <-ctx.Done():

0 commit comments

Comments
 (0)