OSDN Git Service

Hulk did something
[bytom/vapor.git] / protocol / state / blockindex.go
index 0a610f2..df04fa7 100644 (file)
@@ -32,9 +32,6 @@ type BlockNode struct {
        Bits                   uint64
        TransactionsMerkleRoot bc.Hash
        TransactionStatusHash  bc.Hash
-       Proof                  bc.Proof
-       Coinbase               []byte
-       Extra                  []byte
 }
 
 func NewBlockNode(bh *types.BlockHeader, parent *BlockNode) (*BlockNode, error) {
@@ -43,31 +40,24 @@ 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
 }
 
@@ -82,16 +72,12 @@ func (node *BlockNode) BlockHeader() *types.BlockHeader {
                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,
        }
 }