MCPcopy Create free account
hub / github.com/CPChain/chain / DumpBlock

Method DumpBlock

protocols/cpc/api.go:287–309  ·  view source on GitHub ↗

DumpBlock retrieves the entire state of the database at a given block.

(blockNr rpc.BlockNumber)

Source from the content-addressed store, hash-verified

285
286// DumpBlock retrieves the entire state of the database at a given block.
287func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error) {
288 if blockNr == rpc.PendingBlockNumber {
289 // If we're dumping the pending state, we need to request
290 // both the pending block as well as the pending state from
291 // the miner and operate on those
292 _, stateDb := api.cpc.miner.Pending()
293 return stateDb.RawDump(), nil
294 }
295 var block *types.Block
296 if blockNr == rpc.LatestBlockNumber {
297 block = api.cpc.blockchain.CurrentBlock()
298 } else {
299 block = api.cpc.blockchain.GetBlockByNumber(uint64(blockNr))
300 }
301 if block == nil {
302 return state.Dump{}, fmt.Errorf("block #%d not found", blockNr)
303 }
304 stateDb, err := api.cpc.BlockChain().StateAt(block.StateRoot())
305 if err != nil {
306 return state.Dump{}, err
307 }
308 return stateDb.RawDump(), nil
309}
310
311// DporPeers retrieves all the information we know about each individual peer
312// at the dpor protocol level

Callers

nothing calls this directly

Calls 7

StateRootMethod · 0.95
RawDumpMethod · 0.80
PendingMethod · 0.65
CurrentBlockMethod · 0.65
GetBlockByNumberMethod · 0.65
StateAtMethod · 0.65
BlockChainMethod · 0.65

Tested by

no test coverage detected