mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-23 14:32:32 +00:00
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:
parent
50b6e10b57
commit
b25bf566b0
11
accept.go
11
accept.go
@ -91,12 +91,11 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, fastAdd bool) error
|
|||||||
return RuleError(str)
|
return RuleError(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the latest known good checkpoint and prevent blocks which fork
|
// Find the previous checkpoint and prevent blocks which fork the main
|
||||||
// the main chain before it. This prevents storage of new, otherwise
|
// chain before it. This prevents storage of new, otherwise valid,
|
||||||
// valid, blocks which build off of old blocks that are likely at a
|
// blocks which build off of old blocks that are likely at a much easier
|
||||||
// much easier difficulty and therefore could be used to waste cache and
|
// difficulty and therefore could be used to waste cache and disk space.
|
||||||
// disk space.
|
checkpointBlock, err := b.findPreviousCheckpoint()
|
||||||
checkpointBlock, err := b.findLatestKnownCheckpoint()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -146,11 +146,11 @@ func (b *BlockChain) verifyCheckpoint(height int64, hash *btcwire.ShaHash) bool
|
|||||||
return true
|
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
|
// 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
|
// associated block. It returns nil if a checkpoint can't be found (this should
|
||||||
// really only happen for blocks before the first checkpoint).
|
// 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 {
|
if b.noCheckpoints || b.checkpointData() == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -117,14 +117,14 @@ func (b *BlockChain) ProcessBlock(block *btcutil.Block, fastAdd bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the latest known checkpoint and perform some additional checks
|
// Find the previous checkpoint and perform some additional checks based
|
||||||
// based on the checkpoint. This provides a few nice properties such as
|
// on the checkpoint. This provides a few nice properties such as
|
||||||
// preventing old side chain blocks before the last checkpoint,
|
// preventing old side chain blocks before the last checkpoint,
|
||||||
// rejecting easy to mine, but otherwise bogus, blocks that could be
|
// rejecting easy to mine, but otherwise bogus, blocks that could be
|
||||||
// used to eat memory, and ensuring expected (versus claimed) proof of
|
// 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
|
blockHeader := &block.MsgBlock().Header
|
||||||
checkpointBlock, err := b.findLatestKnownCheckpoint()
|
checkpointBlock, err := b.findPreviousCheckpoint()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user