()
| 1047 | } |
| 1048 | |
| 1049 | func (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 | |
| 1071 | func (c *Chain) stat() { |
| 1072 | var ( |
no test coverage detected