forked from cerc-io/plugeth
all: change chain head markers from block to header (#26777)
This commit is contained in:
+23
-15
@@ -267,20 +267,24 @@ func (api *DebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
|
||||
_, stateDb := api.eth.miner.Pending()
|
||||
return stateDb.RawDump(opts), nil
|
||||
}
|
||||
var block *types.Block
|
||||
var header *types.Header
|
||||
if blockNr == rpc.LatestBlockNumber {
|
||||
block = api.eth.blockchain.CurrentBlock()
|
||||
header = api.eth.blockchain.CurrentBlock()
|
||||
} else if blockNr == rpc.FinalizedBlockNumber {
|
||||
block = api.eth.blockchain.CurrentFinalizedBlock()
|
||||
header = api.eth.blockchain.CurrentFinalBlock()
|
||||
} else if blockNr == rpc.SafeBlockNumber {
|
||||
block = api.eth.blockchain.CurrentSafeBlock()
|
||||
header = api.eth.blockchain.CurrentSafeBlock()
|
||||
} else {
|
||||
block = api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
||||
block := api.eth.blockchain.GetBlockByNumber(uint64(blockNr))
|
||||
if block == nil {
|
||||
return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
|
||||
}
|
||||
header = block.Header()
|
||||
}
|
||||
if block == nil {
|
||||
if header == nil {
|
||||
return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
|
||||
}
|
||||
stateDb, err := api.eth.BlockChain().StateAt(block.Root())
|
||||
stateDb, err := api.eth.BlockChain().StateAt(header.Root)
|
||||
if err != nil {
|
||||
return state.Dump{}, err
|
||||
}
|
||||
@@ -347,20 +351,24 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex
|
||||
// the miner and operate on those
|
||||
_, stateDb = api.eth.miner.Pending()
|
||||
} else {
|
||||
var block *types.Block
|
||||
var header *types.Header
|
||||
if number == rpc.LatestBlockNumber {
|
||||
block = api.eth.blockchain.CurrentBlock()
|
||||
header = api.eth.blockchain.CurrentBlock()
|
||||
} else if number == rpc.FinalizedBlockNumber {
|
||||
block = api.eth.blockchain.CurrentFinalizedBlock()
|
||||
header = api.eth.blockchain.CurrentFinalBlock()
|
||||
} else if number == rpc.SafeBlockNumber {
|
||||
block = api.eth.blockchain.CurrentSafeBlock()
|
||||
header = api.eth.blockchain.CurrentSafeBlock()
|
||||
} else {
|
||||
block = api.eth.blockchain.GetBlockByNumber(uint64(number))
|
||||
block := api.eth.blockchain.GetBlockByNumber(uint64(number))
|
||||
if block == nil {
|
||||
return state.IteratorDump{}, fmt.Errorf("block #%d not found", number)
|
||||
}
|
||||
header = block.Header()
|
||||
}
|
||||
if block == nil {
|
||||
if header == nil {
|
||||
return state.IteratorDump{}, fmt.Errorf("block #%d not found", number)
|
||||
}
|
||||
stateDb, err = api.eth.BlockChain().StateAt(block.Root())
|
||||
stateDb, err = api.eth.BlockChain().StateAt(header.Root)
|
||||
if err != nil {
|
||||
return state.IteratorDump{}, err
|
||||
}
|
||||
@@ -552,7 +560,7 @@ func (api *DebugAPI) GetAccessibleState(from, to rpc.BlockNumber) (uint64, error
|
||||
if block == nil {
|
||||
return 0, fmt.Errorf("current block missing")
|
||||
}
|
||||
return block.NumberU64(), nil
|
||||
return block.Number.Uint64(), nil
|
||||
}
|
||||
return uint64(num.Int64()), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user