OSDN Git Service

Add the basic framework for voting processing for dpos
[bytom/vapor.git] / protocol / bc / types / map.go
index e68f17a..8dd10a4 100644 (file)
@@ -2,6 +2,7 @@ package types
 
 import (
        "github.com/vapor/consensus"
+       "github.com/vapor/crypto/sha3pool"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/vm"
        "github.com/vapor/protocol/vm/vmutil"
@@ -213,7 +214,6 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                        r := bc.NewRetirement(src, uint64(i))
                        resultID = addEntry(r)
                } else {
-
                        // non-retirement
                        prog := &bc.Program{out.VMVersion, out.ControlProgram}
                        o := bc.NewOutput(src, prog, uint64(i))
@@ -228,7 +228,8 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                resultIDs = append(resultIDs, &resultID)
                mux.WitnessDestinations = append(mux.WitnessDestinations, dest)
        }
-       h := bc.NewTxHeader(tx.Version, tx.SerializedSize, tx.TimeRange, resultIDs)
+       refdatahash := hashData(tx.ReferenceData)
+       h := bc.NewTxHeader(tx.Version, tx.SerializedSize, &refdatahash, tx.TimeRange, resultIDs)
        return addEntry(h), h, entryMap
 }
 
@@ -251,3 +252,9 @@ func MapBlock(old *Block) *bc.Block {
        }
        return b
 }
+
+func hashData(data []byte) bc.Hash {
+       var b32 [32]byte
+       sha3pool.Sum256(b32[:], data)
+       return bc.NewHash(b32)
+}