diff options
author | Aaron Buchwald <[email protected]> | 2020-10-15 21:40:14 -0400 |
---|---|---|
committer | Aaron Buchwald <[email protected]> | 2020-10-15 21:40:14 -0400 |
commit | 3b3cf1aeaa1eb41f64383e2a18c00240ffde7d2b (patch) | |
tree | 727ff40acaa5b1566f4839ea1c0a623a614307fd /rpc | |
parent | 8a8ef56dd1a0f2cd28c6d4b3a579b16cdda6e2cf (diff) |
Revert changes to unmarshalling of latest block number
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/types.go | 9 |
1 files 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": |