Bits uint64
TransactionsMerkleRoot bc.Hash
TransactionStatusHash bc.Hash
- Proof bc.Proof
- Coinbase []byte
- Extra []byte
}
func NewBlockNode(bh *types.BlockHeader, parent *BlockNode) (*BlockNode, error) {
}
node := &BlockNode{
- Parent: parent,
- Hash: bh.Hash(),
- //WorkSum: difficulty.CalcWork(bh.Bits),
- Version: bh.Version,
- Height: bh.Height,
- Timestamp: bh.Timestamp,
- //Nonce: bh.Nonce,
- //Bits: bh.Bits,
+ Parent: parent,
+ Hash: bh.Hash(),
+ WorkSum: difficulty.CalcWork(bh.Bits),
+ Version: bh.Version,
+ Height: bh.Height,
+ Timestamp: bh.Timestamp,
+ Nonce: bh.Nonce,
+ Bits: bh.Bits,
TransactionsMerkleRoot: bh.TransactionsMerkleRoot,
TransactionStatusHash: bh.TransactionStatusHash,
- Proof: bc.Proof{
- Sign: bh.Proof.Sign,
- ControlProgram: bh.Proof.ControlProgram,
- },
- Coinbase: bh.Coinbase,
- Extra: bh.Extra,
}
- /*
- if bh.Height == 0 {
- node.Seed = consensus.InitialSeed
- } else {
- node.Seed = parent.CalcNextSeed()
- node.WorkSum = node.WorkSum.Add(parent.WorkSum, node.WorkSum)
- }
- */
+
+ if bh.Height == 0 {
+ node.Seed = consensus.InitialSeed
+ } else {
+ node.Seed = parent.CalcNextSeed()
+ node.WorkSum = node.WorkSum.Add(parent.WorkSum, node.WorkSum)
+ }
return node, nil
}
Height: node.Height,
PreviousBlockHash: previousBlockHash,
Timestamp: node.Timestamp,
- Proof: types.Proof{
- Sign: node.Proof.Sign,
- ControlProgram: node.Proof.ControlProgram,
- },
+ Nonce: node.Nonce,
+ Bits: node.Bits,
BlockCommitment: types.BlockCommitment{
TransactionsMerkleRoot: node.TransactionsMerkleRoot,
TransactionStatusHash: node.TransactionStatusHash,
},
- Coinbase: node.Coinbase,
- Extra: node.Extra,
}
}