MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / fetchBlockByCount

Method fetchBlockByCount

blockproducer/chain_io.go:73–90  ·  view source on GitHub ↗
(count uint32)

Source from the content-addressed store, hash-verified

71}
72
73func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
74 var node = c.head().ancestorByCount(count)
75 // Not found
76 if node == nil {
77 return
78 }
79 // OK, and block is cached
80 if b = node.load(); b != nil {
81 height = node.height
82 return
83 }
84 // Not cached, read from database
85 if b, err = c.loadBlock(node.hash); err != nil {
86 return
87 }
88 height = node.height
89 return
90}
91
92func (c *Chain) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
93 c.RLock()

Callers 2

TestChainFunction · 0.45
FetchBlockByCountMethod · 0.45

Calls 4

headMethod · 0.95
loadBlockMethod · 0.95
ancestorByCountMethod · 0.45
loadMethod · 0.45

Tested by 1

TestChainFunction · 0.36