diff --git a/.gitignore b/.gitignore index 8bd46d02b..bd376bab8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ _testmain.go .vscode debug debug.test +__debug_bin # CI version.txt diff --git a/blockdag/accept.go b/blockdag/accept.go index b387079e7..2ee3fa966 100644 --- a/blockdag/accept.go +++ b/blockdag/accept.go @@ -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 // position of the block within the block DAG. - bluestParent := parents.bluest() - err = dag.checkBlockContext(block, parents, bluestParent, flags) + err = dag.checkBlockContext(block, parents, flags) if err != nil { 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 fastAdd := flags&BFFastAdd == BFFastAdd + bluestParent := parents.bluest() if !fastAdd { if err := dag.validateAllTxsFinalized(block, newNode, bluestParent); err != nil { return err diff --git a/blockdag/validate.go b/blockdag/validate.go index 59d7aee8a..efa9d5083 100644 --- a/blockdag/validate.go +++ b/blockdag/validate.go @@ -657,7 +657,8 @@ func validateParents(blockHeader *wire.BlockHeader, parents blockSet) error { // for how the flags modify its behavior. // // 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 err := validateParents(&block.MsgBlock().Header, parents) @@ -1030,7 +1031,7 @@ func (dag *BlockDAG) CheckConnectBlockTemplateNoLock(block *util.Block) error { return err } - err = dag.checkBlockContext(block, parents, dag.selectedTip(), flags) + err = dag.checkBlockContext(block, parents, flags) if err != nil { return err }