mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
chore(eth): always use the latest block number for pending state in RPC calls (#410)
* feat: improve RPC * feat: more * feat: check flag
This commit is contained in:
parent
9e6edc51db
commit
682235849b
2 changed files with 12 additions and 0 deletions
|
|
@ -187,6 +187,10 @@ func (b *EthAPIBackend) Pending() (*types.Block, types.Receipts, *state.StateDB)
|
|||
}
|
||||
|
||||
func (b *EthAPIBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) {
|
||||
// CHANGE(taiko): always use the latest block number for pending state.
|
||||
if b.ChainConfig().Taiko && number == rpc.PendingBlockNumber {
|
||||
number = rpc.LatestBlockNumber
|
||||
}
|
||||
// Pending state is only known by the miner
|
||||
if number == rpc.PendingBlockNumber {
|
||||
block, _, state := b.eth.miner.Pending()
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ func (api *DebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
|
|||
OnlyWithAddresses: true,
|
||||
Max: AccountRangeMaxResults, // Sanity limit over RPC
|
||||
}
|
||||
// CHANGE(taiko): always use the latest block number for pending state.
|
||||
if api.eth.blockchain.Config().Taiko && blockNr == rpc.PendingBlockNumber {
|
||||
blockNr = rpc.LatestBlockNumber
|
||||
}
|
||||
if blockNr == rpc.PendingBlockNumber {
|
||||
// If we're dumping the pending state, we need to request
|
||||
// both the pending block as well as the pending state from
|
||||
|
|
@ -138,6 +142,10 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex
|
|||
var err error
|
||||
|
||||
if number, ok := blockNrOrHash.Number(); ok {
|
||||
// CHANGE(taiko): always use the latest block number for pending state.
|
||||
if api.eth.blockchain.Config().Taiko && number == rpc.PendingBlockNumber {
|
||||
number = rpc.LatestBlockNumber
|
||||
}
|
||||
if number == rpc.PendingBlockNumber {
|
||||
// If we're dumping the pending state, we need to request
|
||||
// both the pending block as well as the pending state from
|
||||
|
|
|
|||
Loading…
Reference in a new issue