mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
api/debug: Fix pending block issues in DumpBlock
This commit is contained in:
parent
1840ad48b6
commit
6018907243
1 changed files with 10 additions and 10 deletions
20
eth/api.go
20
eth/api.go
|
|
@ -283,16 +283,17 @@ func NewPublicDebugAPI(eth *Ethereum) *PublicDebugAPI {
|
||||||
|
|
||||||
// DumpBlock retrieves the entire state of the database at a given block.
|
// DumpBlock retrieves the entire state of the database at a given block.
|
||||||
func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
|
func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
|
||||||
|
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
|
||||||
|
// the miner and operate on those
|
||||||
|
_, stateDb := api.eth.miner.Pending()
|
||||||
|
return stateDb.RawDump(), nil
|
||||||
|
}
|
||||||
var block *types.Block
|
var block *types.Block
|
||||||
|
if blockNr == rpc.LatestBlockNumber {
|
||||||
switch blockNr {
|
|
||||||
case rpc.PendingBlockNumber:
|
|
||||||
// Pending block is only known by the miner
|
|
||||||
block = api.eth.miner.PendingBlock()
|
|
||||||
case rpc.LatestBlockNumber:
|
|
||||||
block = api.eth.blockchain.CurrentBlock()
|
block = api.eth.blockchain.CurrentBlock()
|
||||||
default:
|
} else {
|
||||||
block = api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
block = api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
||||||
}
|
}
|
||||||
if block == nil {
|
if block == nil {
|
||||||
|
|
@ -362,9 +363,8 @@ func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config *vm.LogConfig
|
||||||
|
|
||||||
// TraceBlockByNumber processes the block by canonical block number.
|
// TraceBlockByNumber processes the block by canonical block number.
|
||||||
func (api *PrivateDebugAPI) TraceBlockByNumber(blockNr rpc.BlockNumber, config *vm.LogConfig) BlockTraceResult {
|
func (api *PrivateDebugAPI) TraceBlockByNumber(blockNr rpc.BlockNumber, config *vm.LogConfig) BlockTraceResult {
|
||||||
|
|
||||||
var block *types.Block
|
|
||||||
// Fetch the block that we aim to reprocess
|
// Fetch the block that we aim to reprocess
|
||||||
|
var block *types.Block
|
||||||
switch blockNr {
|
switch blockNr {
|
||||||
case rpc.PendingBlockNumber:
|
case rpc.PendingBlockNumber:
|
||||||
// Pending block is only known by the miner
|
// Pending block is only known by the miner
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue