Skip to content

Commit

Permalink
ethclient: add 'finalized' and 'safe' block number support (ethereum#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield authored and HanWang233 committed Sep 11, 2022
1 parent 746fe19 commit fc8b470
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@ func toBlockNumArg(number *big.Int) string {
if number.Cmp(pending) == 0 {
return "pending"
}
finalized := big.NewInt(int64(rpc.FinalizedBlockNumber))
if number.Cmp(finalized) == 0 {
return "finalized"
}
safe := big.NewInt(int64(rpc.SafeBlockNumber))
if number.Cmp(safe) == 0 {
return "safe"
}
return hexutil.EncodeBig(number)
}

Expand Down
8 changes: 8 additions & 0 deletions ethclient/gethclient/gethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ func toBlockNumArg(number *big.Int) string {
if number.Cmp(pending) == 0 {
return "pending"
}
finalized := big.NewInt(int64(rpc.FinalizedBlockNumber))
if number.Cmp(finalized) == 0 {
return "finalized"
}
safe := big.NewInt(int64(rpc.SafeBlockNumber))
if number.Cmp(safe) == 0 {
return "safe"
}
return hexutil.EncodeBig(number)
}

Expand Down

0 comments on commit fc8b470

Please sign in to comment.