From b25bf566b09bde9144a08af8ba1a693c5dd03c74 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 21 Feb 2014 15:03:44 -0600 Subject: [PATCH] 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. --- accept.go | 11 +++++------ checkpoints.go | 4 ++-- process.go | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/accept.go b/accept.go index 98674eec0..f6b288fcb 100644 --- a/accept.go +++ b/accept.go @@ -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 } diff --git a/checkpoints.go b/checkpoints.go index c52218cfb..ade891d91 100644 --- a/checkpoints.go +++ b/checkpoints.go @@ -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 } diff --git a/process.go b/process.go index 281a36c06..a9d26a8ca 100644 --- a/process.go +++ b/process.go @@ -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 }