[NOD-232] Remove diff and diffChild from blockNode (#336)

This commit is contained in:
Ori Newman 2019-07-02 11:01:41 +03:00 committed by Svarog
parent 589763e8ec
commit e2f8d4e0aa
3 changed files with 2 additions and 35 deletions

View File

@ -75,14 +75,6 @@ type blockNode struct {
// blueScore is the count of all the blue blocks in this block's past // blueScore is the count of all the blue blocks in this block's past
blueScore uint64 blueScore uint64
// diff is the UTXO representation of the block
// A block's UTXO is reconstituted by applying diffWith on every block in the chain of diffChildren
// from the virtual block down to the block. See diffChild
diff *UTXODiff
// diffChild is the child that diff will be built from. See diff
diffChild *blockNode
// hash is the double sha 256 of the block. // hash is the double sha 256 of the block.
hash *daghash.Hash hash *daghash.Hash

View File

@ -6,8 +6,6 @@ package blockdag
import ( import (
"fmt" "fmt"
"time"
"github.com/daglabs/btcd/dagconfig" "github.com/daglabs/btcd/dagconfig"
"github.com/daglabs/btcd/txscript" "github.com/daglabs/btcd/txscript"
"github.com/daglabs/btcd/util" "github.com/daglabs/btcd/util"
@ -237,8 +235,7 @@ func (dag *BlockDAG) IsCheckpointCandidate(block *util.Block) (bool, error) {
// This should always succeed since the check above already made sure it // This should always succeed since the check above already made sure it
// is CheckpointConfirmations back, but be safe in case the constant // is CheckpointConfirmations back, but be safe in case the constant
// changes. // changes.
nextNode := node.diffChild if len(node.children) == 0 {
if nextNode == nil {
return false, nil return false, nil
} }
@ -247,16 +244,6 @@ func (dag *BlockDAG) IsCheckpointCandidate(block *util.Block) (bool, error) {
return false, nil return false, nil
} }
// A checkpoint must have timestamps for the block and the blocks on
// either side of it in order (due to the median time allowance this is
// not always the case).
prevTime := time.Unix(node.selectedParent.timestamp, 0)
curTime := block.MsgBlock().Header.Timestamp
nextTime := time.Unix(nextNode.timestamp, 0)
if prevTime.After(curTime) || nextTime.Before(curTime) {
return false, nil
}
// A checkpoint must have transactions that only contain standard // A checkpoint must have transactions that only contain standard
// scripts. // scripts.
for _, tx := range block.Transactions() { for _, tx := range block.Transactions() {

View File

@ -175,21 +175,9 @@ func (dag *BlockDAG) ProcessBlock(block *util.Block, flags BehaviorFlags) (isOrp
} }
} }
blockHeader := &block.MsgBlock().Header
if dag.lastFinalityPoint != nil {
// Ensure the block timestamp is after the finality point timestamp.
lastFinalityPoint := time.Unix(dag.lastFinalityPoint.timestamp, 0)
if blockHeader.Timestamp.Before(lastFinalityPoint) {
str := fmt.Sprintf("block %s has timestamp %s before "+
"last finality point timestamp %s", blockHash,
blockHeader.Timestamp, lastFinalityPoint)
return false, 0, ruleError(ErrFinalityPointTimeTooOld, str)
}
}
// Handle orphan blocks. // Handle orphan blocks.
allParentsExist := true allParentsExist := true
for _, parentHash := range blockHeader.ParentHashes { for _, parentHash := range block.MsgBlock().Header.ParentHashes {
parentExists, err := dag.BlockExists(parentHash) parentExists, err := dag.BlockExists(parentHash)
if err != nil { if err != nil {
return false, 0, err return false, 0, err