From e2f8d4e0aad55abbc363c7cf511dafbbe84d2b65 Mon Sep 17 00:00:00 2001
From: Ori Newman <orinewman1@gmail.com>
Date: Tue, 2 Jul 2019 11:01:41 +0300
Subject: [PATCH] [NOD-232] Remove diff and diffChild from blockNode (#336)

---
 blockdag/blocknode.go   |  8 --------
 blockdag/checkpoints.go | 15 +--------------
 blockdag/process.go     | 14 +-------------
 3 files changed, 2 insertions(+), 35 deletions(-)

diff --git a/blockdag/blocknode.go b/blockdag/blocknode.go
index c558f97ce..8e501b40b 100644
--- a/blockdag/blocknode.go
+++ b/blockdag/blocknode.go
@@ -75,14 +75,6 @@ type blockNode struct {
 	// blueScore is the count of all the blue blocks in this block's past
 	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 *daghash.Hash
 
diff --git a/blockdag/checkpoints.go b/blockdag/checkpoints.go
index 072a66758..120ca0137 100644
--- a/blockdag/checkpoints.go
+++ b/blockdag/checkpoints.go
@@ -6,8 +6,6 @@ package blockdag
 
 import (
 	"fmt"
-	"time"
-
 	"github.com/daglabs/btcd/dagconfig"
 	"github.com/daglabs/btcd/txscript"
 	"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
 	// is CheckpointConfirmations back, but be safe in case the constant
 	// changes.
-	nextNode := node.diffChild
-	if nextNode == nil {
+	if len(node.children) == 0 {
 		return false, nil
 	}
 
@@ -247,16 +244,6 @@ func (dag *BlockDAG) IsCheckpointCandidate(block *util.Block) (bool, error) {
 		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
 	// scripts.
 	for _, tx := range block.Transactions() {
diff --git a/blockdag/process.go b/blockdag/process.go
index 41167cd20..514e8cdf1 100644
--- a/blockdag/process.go
+++ b/blockdag/process.go
@@ -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.
 	allParentsExist := true
-	for _, parentHash := range blockHeader.ParentHashes {
+	for _, parentHash := range block.MsgBlock().Header.ParentHashes {
 		parentExists, err := dag.BlockExists(parentHash)
 		if err != nil {
 			return false, 0, err