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

Method pruneBlockCache

sqlchain/chain.go:1049–1069  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1047}
1048
1049func (c *Chain) pruneBlockCache() {
1050 var (
1051 head = c.rt.getHead().node
1052 nextTurn = c.rt.getNextTurn()
1053 lastCnt int32
1054 )
1055 if head == nil {
1056 return
1057 }
1058 lastCnt = nextTurn - c.rt.blockCacheTTL
1059 if h := c.rt.getLastBillingHeight(); h < lastCnt {
1060 lastCnt = h // also keep cache for billing if possible
1061 }
1062 // Move to last count position
1063 for ; head != nil && head.count > lastCnt; head = head.parent {
1064 }
1065 // Prune block references
1066 for ; head != nil && head.clear(); head = head.parent {
1067 atomic.AddInt32(&c.cachedBlockCount, -1)
1068 }
1069}
1070
1071func (c *Chain) stat() {
1072 var (

Callers 2

runCurrentTurnMethod · 0.95
syncMethod · 0.95

Calls 4

getNextTurnMethod · 0.80
getLastBillingHeightMethod · 0.80
getHeadMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected