aboutsummaryrefslogtreecommitdiff
path: root/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'rpc')
-rw-r--r--rpc/types.go9
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":