blockchain: Rename last prune time field.

This renames the field that tracks the last time the stake nodes were
pruned to lastPruneTime to more accurately reflect its purpose.
This commit is contained in:
Dave Collins 2020-07-24 02:48:07 -05:00
parent f5085109e0
commit b1b24a0cfd
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -11,15 +11,15 @@ const pruningIntervalInMinutes = 5
// chainPruner is used to occasionally prune the blockchain of old nodes that
// can be freed to the garbage collector.
type chainPruner struct {
chain *BlockChain
lastNodeInsertTime time.Time
chain *BlockChain
lastPruneTime time.Time
}
// newChainPruner returns a new chain pruner.
func newChainPruner(chain *BlockChain) *chainPruner {
return &chainPruner{
chain: chain,
lastNodeInsertTime: time.Now(),
chain: chain,
lastPruneTime: time.Now(),
}
}
@ -29,11 +29,11 @@ func newChainPruner(chain *BlockChain) *chainPruner {
// pruneChainIfNeeded must be called with the chainLock held for writes.
func (c *chainPruner) pruneChainIfNeeded() {
now := time.Now()
duration := now.Sub(c.lastNodeInsertTime)
duration := now.Sub(c.lastPruneTime)
if duration < time.Minute*pruningIntervalInMinutes {
return
}
c.lastNodeInsertTime = now
c.lastPruneTime = now
c.chain.pruneStakeNodes()
}