mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-251] Use bluest parent anywhere validating difficulty, instead of selectedTip (#348)
This commit is contained in:
parent
96842353de
commit
7a4deb6f18
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,6 +38,7 @@ _testmain.go
|
|||||||
.vscode
|
.vscode
|
||||||
debug
|
debug
|
||||||
debug.test
|
debug.test
|
||||||
|
__debug_bin
|
||||||
|
|
||||||
# CI
|
# CI
|
||||||
version.txt
|
version.txt
|
||||||
|
@ -30,8 +30,7 @@ func (dag *BlockDAG) maybeAcceptBlock(block *util.Block, flags BehaviorFlags) er
|
|||||||
|
|
||||||
// The block must pass all of the validation rules which depend on the
|
// The block must pass all of the validation rules which depend on the
|
||||||
// position of the block within the block DAG.
|
// position of the block within the block DAG.
|
||||||
bluestParent := parents.bluest()
|
err = dag.checkBlockContext(block, parents, flags)
|
||||||
err = dag.checkBlockContext(block, parents, bluestParent, flags)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -59,6 +58,7 @@ func (dag *BlockDAG) maybeAcceptBlock(block *util.Block, flags BehaviorFlags) er
|
|||||||
|
|
||||||
// Make sure that all the block's transactions are finalized
|
// Make sure that all the block's transactions are finalized
|
||||||
fastAdd := flags&BFFastAdd == BFFastAdd
|
fastAdd := flags&BFFastAdd == BFFastAdd
|
||||||
|
bluestParent := parents.bluest()
|
||||||
if !fastAdd {
|
if !fastAdd {
|
||||||
if err := dag.validateAllTxsFinalized(block, newNode, bluestParent); err != nil {
|
if err := dag.validateAllTxsFinalized(block, newNode, bluestParent); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -657,7 +657,8 @@ func validateParents(blockHeader *wire.BlockHeader, parents blockSet) error {
|
|||||||
// for how the flags modify its behavior.
|
// for how the flags modify its behavior.
|
||||||
//
|
//
|
||||||
// This function MUST be called with the dag state lock held (for writes).
|
// This function MUST be called with the dag state lock held (for writes).
|
||||||
func (dag *BlockDAG) checkBlockContext(block *util.Block, parents blockSet, bluestParent *blockNode, flags BehaviorFlags) error {
|
func (dag *BlockDAG) checkBlockContext(block *util.Block, parents blockSet, flags BehaviorFlags) error {
|
||||||
|
bluestParent := parents.bluest()
|
||||||
fastAdd := flags&BFFastAdd == BFFastAdd
|
fastAdd := flags&BFFastAdd == BFFastAdd
|
||||||
|
|
||||||
err := validateParents(&block.MsgBlock().Header, parents)
|
err := validateParents(&block.MsgBlock().Header, parents)
|
||||||
@ -1030,7 +1031,7 @@ func (dag *BlockDAG) CheckConnectBlockTemplateNoLock(block *util.Block) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dag.checkBlockContext(block, parents, dag.selectedTip(), flags)
|
err = dag.checkBlockContext(block, parents, flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user