OSDN Git Service

init delete the pow related (#55)
[bytom/vapor.git] / protocol / bc / types / map.go
index 8dd10a4..a1a23a9 100644 (file)
@@ -2,7 +2,6 @@ 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"
@@ -35,17 +34,8 @@ func MapTx(oldTx *TxData) *bc.Tx {
 
                case *bc.Coinbase:
                        ord = 0
-               case *bc.Claim:
-                       ord = 0
-               case *bc.Dpos:
-                       ord = e.Ordinal
-                       //spentOutputIDs[*e.SpentOutputId] = true
-                       /*
-                               if *e.WitnessDestination.Value.AssetId == *consensus.BTMAssetID {
-                                       tx.GasInputIDs = append(tx.GasInputIDs, id)
-                               }
-                       */
-                       continue
+                       tx.GasInputIDs = append(tx.GasInputIDs, id)
+
                default:
                        continue
                }
@@ -72,10 +62,8 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
 
        var (
                spends    []*bc.Spend
-               dposs     []*bc.Dpos
                issuances []*bc.Issuance
                coinbase  *bc.Coinbase
-               claim     *bc.Claim
        )
 
        muxSources := make([]*bc.ValueSource, len(tx.Inputs))
@@ -133,44 +121,6 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                                Ref:   &coinbaseID,
                                Value: &out.AssetAmount,
                        }
-               case *ClaimInput:
-                       // create entry for prevout
-                       prog := &bc.Program{VmVersion: inp.VMVersion, Code: inp.ControlProgram}
-                       src := &bc.ValueSource{
-                               Ref:      &inp.SourceID,
-                               Value:    &inp.AssetAmount,
-                               Position: inp.SourcePosition,
-                       }
-                       prevout := bc.NewOutput(src, prog, 0) // ordinal doesn't matter for prevouts, only for result outputs
-                       prevoutID := addEntry(prevout)
-
-                       claim = bc.NewClaim(&prevoutID, uint64(i), input.Peginwitness)
-                       claim.WitnessArguments = inp.Arguments
-                       claimID := addEntry(claim)
-                       muxSources[i] = &bc.ValueSource{
-                               Ref:   &claimID,
-                               Value: &inp.AssetAmount,
-                       }
-               case *DposTx:
-                       // create entry for prevout
-                       prog := &bc.Program{VmVersion: inp.VMVersion, Code: inp.ControlProgram}
-                       src := &bc.ValueSource{
-                               Ref:      &inp.SourceID,
-                               Value:    &inp.AssetAmount,
-                               Position: inp.SourcePosition,
-                       }
-                       prevout := bc.NewOutput(src, prog, 0) // ordinal doesn't matter for prevouts, only for result outputs
-                       prevoutID := addEntry(prevout)
-                       // create entry for dpos
-                       dpos := bc.NewDpos(&prevoutID, uint64(i), uint32(inp.Type), inp.Stake, inp.From, inp.To, inp.Info)
-                       dpos.WitnessArguments = inp.Arguments
-                       dposID := addEntry(dpos)
-                       // setup mux
-                       muxSources[i] = &bc.ValueSource{
-                               Ref:   &dposID,
-                               Value: &inp.AssetAmount,
-                       }
-                       dposs = append(dposs, dpos)
                }
        }
 
@@ -186,20 +136,10 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                issuance.SetDestination(&muxID, issuance.Value, issuance.Ordinal)
        }
 
-       // connect the inputs to the mux
-       for _, dpos := range dposs {
-               spentOutput := entryMap[*dpos.SpentOutputId].(*bc.Output)
-               dpos.SetDestination(&muxID, spentOutput.Source.Value, dpos.Ordinal)
-       }
-
        if coinbase != nil {
                coinbase.SetDestination(&muxID, mux.Sources[0].Value, 0)
        }
 
-       if claim != nil {
-               claim.SetDestination(&muxID, mux.Sources[0].Value, 0)
-       }
-
        // convert types.outputs to the bc.output
        var resultIDs []*bc.Hash
        for i, out := range tx.Outputs {
@@ -228,14 +168,13 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                resultIDs = append(resultIDs, &resultID)
                mux.WitnessDestinations = append(mux.WitnessDestinations, dest)
        }
-       refdatahash := hashData(tx.ReferenceData)
-       h := bc.NewTxHeader(tx.Version, tx.SerializedSize, &refdatahash, tx.TimeRange, resultIDs)
+
+       h := bc.NewTxHeader(tx.Version, tx.SerializedSize, tx.TimeRange, resultIDs)
        return addEntry(h), h, entryMap
 }
 
 func mapBlockHeader(old *BlockHeader) (bc.Hash, *bc.BlockHeader) {
-       proof := &bc.Proof{Sign: old.Proof.Sign, ControlProgram: old.Proof.ControlProgram}
-       bh := bc.NewBlockHeader(old.Version, old.Height, &old.PreviousBlockHash, old.Timestamp, &old.TransactionsMerkleRoot, &old.TransactionStatusHash, proof, old.Extra, old.Coinbase)
+       bh := bc.NewBlockHeader(old.Version, old.Height, &old.PreviousBlockHash, old.Timestamp, &old.TransactionsMerkleRoot, &old.TransactionStatusHash)
        return bc.EntryID(bh), bh
 }
 
@@ -252,9 +191,3 @@ 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)
-}