mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-232] Remove diff and diffChild from blockNode (#336)
This commit is contained in:
parent
589763e8ec
commit
e2f8d4e0aa
@ -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
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user