func (c *chainPruner) pruneChainIfNeeded() error {
	now := time.Now()
	duration := now.Sub(c.lastNodeInsertTime)
	if duration < time.Minute*pruningIntervalInMinutes {
		return nil
	}
	c.lastNodeInsertTime = now
	return c.chain.pruneNodes()
}
pruneChainIfNeeded checks the current time versus the time of the last pruning.
If the blockchain hasn't been pruned in this time, it initiates a new pruning.

pruneChainIfNeeded must be called with the chainLock held for writes.
package blockchain
import (
	"time"
)
const pruningIntervalInMinutes = 5
type chainPruner struct {
	chain              *BlockChain
	lastNodeInsertTime time.Time
}
func newChainPruner(chain *BlockChain) *chainPruner {
	return &chainPruner{
		chain:              chain,
		lastNodeInsertTime: time.Now(),
	}
}