From 3b3cf1aeaa1eb41f64383e2a18c00240ffde7d2b Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 15 Oct 2020 21:40:14 -0400 Subject: Revert changes to unmarshalling of latest block number --- rpc/types.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rpc/types.go b/rpc/types.go index 99e29fc..4e62a53 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -92,7 +92,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error { *bn = EarliestBlockNumber return nil case "latest": - *bn = AcceptedBlockNumber + *bn = LatestBlockNumber return nil case "pending": *bn = PendingBlockNumber @@ -117,6 +117,11 @@ func (bn BlockNumber) Int64() int64 { return (int64)(bn) } +// IsAccepted returns true if this blockNumber should be treated as a request for the last accepted block +func (bn BlockNumber) IsAccepted() bool { + return bn < EarliestBlockNumber && bn >= AcceptedBlockNumber +} + type BlockNumberOrHash struct { BlockNumber *BlockNumber `json:"blockNumber,omitempty"` BlockHash *common.Hash `json:"blockHash,omitempty"` @@ -147,7 +152,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error { bnh.BlockNumber = &bn return nil case "latest": - bn := AcceptedBlockNumber + bn := LatestBlockNumber bnh.BlockNumber = &bn return nil case "pending": -- cgit v1.2.3-70-g09d2