Rename findLatestKnownCheckpoint.

The name findLatestKnownCheckpoint is confusing and doesn't really convey
the fact the purpose of the function is to the find the checkpoint prior
to the current known block.

Therefore, rename the function to findPreviousCheckpoint for clarity.

Also, update some comments to follow suit.
This commit is contained in:
Dave Collins 2014-02-21 15:03:44 -06:00
parent 50b6e10b57
commit b25bf566b0
3 changed files with 11 additions and 12 deletions

View file

@ -91,12 +91,11 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, fastAdd bool) error
return RuleError(str)
}
// Find the latest known good checkpoint and prevent blocks which fork
// the main chain before it. This prevents storage of new, otherwise
// valid, blocks which build off of old blocks that are likely at a
// much easier difficulty and therefore could be used to waste cache and
// disk space.
checkpointBlock, err := b.findLatestKnownCheckpoint()
// Find the previous checkpoint and prevent blocks which fork the main
// chain before it. This prevents storage of new, otherwise valid,
// blocks which build off of old blocks that are likely at a much easier
// difficulty and therefore could be used to waste cache and disk space.
checkpointBlock, err := b.findPreviousCheckpoint()
if err != nil {
return err
}

View file

@ -146,11 +146,11 @@ func (b *BlockChain) verifyCheckpoint(height int64, hash *btcwire.ShaHash) bool
return true
}
// findLatestKnownCheckpoint finds the most recent checkpoint that is already
// findPreviousCheckpoint finds the most recent checkpoint that is already
// available in the downloaded portion of the block chain and returns the
// associated block. It returns nil if a checkpoint can't be found (this should
// really only happen for blocks before the first checkpoint).
func (b *BlockChain) findLatestKnownCheckpoint() (*btcutil.Block, error) {
func (b *BlockChain) findPreviousCheckpoint() (*btcutil.Block, error) {
if b.noCheckpoints || b.checkpointData() == nil {
return nil, nil
}

View file

@ -117,14 +117,14 @@ func (b *BlockChain) ProcessBlock(block *btcutil.Block, fastAdd bool) error {
return err
}
// Find the latest known checkpoint and perform some additional checks
// based on the checkpoint. This provides a few nice properties such as
// Find the previous checkpoint and perform some additional checks based
// on the checkpoint. This provides a few nice properties such as
// preventing old side chain blocks before the last checkpoint,
// rejecting easy to mine, but otherwise bogus, blocks that could be
// used to eat memory, and ensuring expected (versus claimed) proof of
// work requirements since the last checkpoint are met.
// work requirements since the previous checkpoint are met.
blockHeader := &block.MsgBlock().Header
checkpointBlock, err := b.findLatestKnownCheckpoint()
checkpointBlock, err := b.findPreviousCheckpoint()
if err != nil {
return err
}