mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
parent
7a64fe44eb
commit
c12d298f1c
13
rpc/types.go
13
rpc/types.go
@ -71,11 +71,12 @@ type BlockNumber int64
|
|||||||
type Timestamp uint64
|
type Timestamp uint64
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FinalizedBlockNumber = BlockNumber(-4)
|
LatestExecutedBlockNumber = BlockNumber(-5)
|
||||||
SafeBlockNumber = BlockNumber(-3)
|
FinalizedBlockNumber = BlockNumber(-4)
|
||||||
PendingBlockNumber = BlockNumber(-2)
|
SafeBlockNumber = BlockNumber(-3)
|
||||||
LatestBlockNumber = BlockNumber(-1)
|
PendingBlockNumber = BlockNumber(-2)
|
||||||
EarliestBlockNumber = BlockNumber(0)
|
LatestBlockNumber = BlockNumber(-1)
|
||||||
|
EarliestBlockNumber = BlockNumber(0)
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
|
// UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
|
||||||
@ -106,6 +107,8 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
|||||||
case "finalized":
|
case "finalized":
|
||||||
*bn = FinalizedBlockNumber
|
*bn = FinalizedBlockNumber
|
||||||
return nil
|
return nil
|
||||||
|
case "latestExecuted":
|
||||||
|
*bn = LatestExecutedBlockNumber
|
||||||
case "null":
|
case "null":
|
||||||
*bn = LatestBlockNumber
|
*bn = LatestBlockNumber
|
||||||
return nil
|
return nil
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
|
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
|
||||||
"github.com/ledgerwatch/erigon/rpc"
|
"github.com/ledgerwatch/erigon/rpc"
|
||||||
"github.com/ledgerwatch/erigon/turbo/adapter"
|
"github.com/ledgerwatch/erigon/turbo/adapter"
|
||||||
|
"github.com/ledgerwatch/log/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// unable to decode supplied params, or an invalid number of parameters
|
// unable to decode supplied params, or an invalid number of parameters
|
||||||
@ -63,10 +64,13 @@ func _GetBlockNumber(requireCanonical bool, blockNrOrHash rpc.BlockNumberOrHash,
|
|||||||
case rpc.PendingBlockNumber:
|
case rpc.PendingBlockNumber:
|
||||||
pendingBlock := filters.LastPendingBlock()
|
pendingBlock := filters.LastPendingBlock()
|
||||||
if pendingBlock == nil {
|
if pendingBlock == nil {
|
||||||
|
log.Warn("no pending block found returning latest executed block")
|
||||||
blockNumber = plainStateBlockNumber
|
blockNumber = plainStateBlockNumber
|
||||||
} else {
|
} else {
|
||||||
return pendingBlock.NumberU64(), pendingBlock.Hash(), false, nil
|
return pendingBlock.NumberU64(), pendingBlock.Hash(), false, nil
|
||||||
}
|
}
|
||||||
|
case rpc.LatestExecutedBlockNumber:
|
||||||
|
blockNumber = plainStateBlockNumber
|
||||||
default:
|
default:
|
||||||
blockNumber = uint64(number.Int64())
|
blockNumber = uint64(number.Int64())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user