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

Method GetSnapshot

consensus/dpor/api.go:19–32  ·  view source on GitHub ↗

GetSnapshot retrieves the state Snapshot at a given block.

(number rpc.BlockNumber)

Source from the content-addressed store, hash-verified

17
18// GetSnapshot retrieves the state Snapshot at a given block.
19func (api *API) GetSnapshot(number rpc.BlockNumber) (*DporSnapshot, error) {
20 // Retrieve the requested block number (or current if none requested)
21 var header *types.Header
22 if number == 0 || number == rpc.LatestBlockNumber {
23 header = api.chain.CurrentHeader()
24 } else {
25 header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
26 }
27 // Ensure we have an actually valid block and return its Snapshot
28 if header == nil {
29 return nil, errUnknownBlock
30 }
31 return api.dpor.dh.snapshot(api.dpor, api.chain, header.Number.Uint64(), header.Hash(), nil)
32}
33
34// GetSnapshotAtHash retrieves the state Snapshot at a given block.
35func (api *API) GetSnapshotAtHash(hash common.Hash) (*DporSnapshot, error) {

Callers

nothing calls this directly

Calls 6

HashMethod · 0.95
Int64Method · 0.80
Uint64Method · 0.80
CurrentHeaderMethod · 0.65
GetHeaderByNumberMethod · 0.65
snapshotMethod · 0.65

Tested by

no test coverage detected