Skip to content

Commit 562be5f

Browse files
committed
ethclient: fix discrepancy between latest/pending blocknumbers
1 parent dde2da0 commit 562be5f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ethclient/ethclient.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,16 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
582582
}
583583

584584
func toBlockNumArg(number *big.Int) string {
585-
if number == nil {
585+
if number == nil || number.Cmp(big.NewInt(int64(rpc.LatestBlockNumber))) == 0 {
586586
return "latest"
587587
}
588-
pending := big.NewInt(-1)
589-
if number.Cmp(pending) == 0 {
588+
if number.Cmp(big.NewInt(int64(rpc.PendingBlockNumber))) == 0 {
590589
return "pending"
591590
}
592-
finalized := big.NewInt(int64(rpc.FinalizedBlockNumber))
593-
if number.Cmp(finalized) == 0 {
591+
if number.Cmp(big.NewInt(int64(rpc.FinalizedBlockNumber))) == 0 {
594592
return "finalized"
595593
}
596-
safe := big.NewInt(int64(rpc.SafeBlockNumber))
597-
if number.Cmp(safe) == 0 {
594+
if number.Cmp(big.NewInt(int64(rpc.SafeBlockNumber))) == 0 {
598595
return "safe"
599596
}
600597
return hexutil.EncodeBig(number)

0 commit comments

Comments
 (0)