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

Method GetBlockNumber

core/headerchain.go:137–147  ·  view source on GitHub ↗

GetBlockNumber retrieves the block number belonging to the given hash from the cache or database

(hash common.Hash)

Source from the content-addressed store, hash-verified

135// GetBlockNumber retrieves the block number belonging to the given hash
136// from the cache or database
137func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 {
138 if cached, ok := hc.numberCache.Get(hash); ok {
139 number := cached.(uint64)
140 return &number
141 }
142 number := rawdb.ReadHeaderNumber(hc.chainDb, hash)
143 if number != nil {
144 hc.numberCache.Add(hash, *number)
145 }
146 return number
147}
148
149// WriteHeader writes a header into the local chain, given that its parent is
150// already known. If the total difficulty of the newly inserted header becomes

Callers 9

GetHeaderByHashMethod · 0.95
mainFunction · 0.45
newAuthFunction · 0.45
mainFunction · 0.45
GetBodyMethod · 0.45
GetBodyRLPMethod · 0.45
GetBlockByHashMethod · 0.45
GetBlocksFromHashMethod · 0.45
reorgMethod · 0.45

Calls 2

GetMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected