OSDN Git Service

fix conflict
[bytom/vapor.git] / protocol / bc / types / map.go
index c7af7ae..8922451 100644 (file)
@@ -24,11 +24,13 @@ func MapTx(oldTx *TxData) *bc.Tx {
        }
 
        spentOutputIDs := make(map[bc.Hash]bool)
+       mainchainOutputIDs := make(map[bc.Hash]bool)
        for id, e := range entries {
                var ord uint64
                switch e := e.(type) {
                case *bc.CrossChainInput:
                        ord = e.Ordinal
+                       mainchainOutputIDs[*e.MainchainOutputId] = true
                        if *e.WitnessDestination.Value.AssetId == *consensus.BTMAssetID {
                                tx.GasInputIDs = append(tx.GasInputIDs, id)
                        }
@@ -57,7 +59,9 @@ func MapTx(oldTx *TxData) *bc.Tx {
        for id := range spentOutputIDs {
                tx.SpentOutputIDs = append(tx.SpentOutputIDs, id)
        }
-       fmt.Println("MapTx end...")
+       for id := range mainchainOutputIDs {
+               tx.MainchainOutputIDs = append(tx.MainchainOutputIDs, id)
+       }
        return tx
 }
 
@@ -131,15 +135,16 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                        spends = append(spends, spend)
 
                case *CrossChainInput:
+                       // TODO: fed peg script
                        prog := &bc.Program{VmVersion: inp.VMVersion, Code: inp.ControlProgram}
                        src := &bc.ValueSource{
                                Ref:      &inp.SourceID,
                                Value:    &inp.AssetAmount,
                                Position: inp.SourcePosition,
                        }
-                       prevout := bc.NewCrossChainOutput(src, prog, 0) // ordinal doesn't matter
+                       prevout := bc.NewIntraChainOutput(src, prog, 0) // ordinal doesn't matter
                        outputID := bc.EntryID(prevout)
-                       crossIn := bc.NewCrossChainInput(&outputID, &inp.AssetAmount, uint64(i))
+                       crossIn := bc.NewCrossChainInput(&outputID, &inp.AssetAmount, prog, uint64(i))
                        crossIn.WitnessArguments = inp.Arguments
                        crossInID := addEntry(crossIn)
                        muxSources[i] = &bc.ValueSource{
@@ -147,7 +152,6 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                                Value: &inp.AssetAmount,
                        }
                        crossIns = append(crossIns, crossIn)
-
                }
        }