OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / protocol / bc / crosschain_output.go
diff --git a/protocol/bc/crosschain_output.go b/protocol/bc/crosschain_output.go
new file mode 100644 (file)
index 0000000..ad2a2cd
--- /dev/null
@@ -0,0 +1,24 @@
+package bc
+
+import "io"
+
+// CrossChainOutput is the result of a transfer of value. The value it contains
+// can never be accessed on side chain, as it has been transfered back to the
+// main chain.
+// CrossChainOutput satisfies the Entry interface.
+// (Not to be confused with the deprecated type TxOutput.)
+
+func (CrossChainOutput) typ() string { return "crosschainoutput1" }
+func (o *CrossChainOutput) writeForHash(w io.Writer) {
+       mustWriteForHash(w, o.Source)
+       mustWriteForHash(w, o.ControlProgram)
+}
+
+// NewCrossChainOutput creates a new CrossChainOutput.
+func NewCrossChainOutput(source *ValueSource, controlProgram *Program, ordinal uint64) *CrossChainOutput {
+       return &CrossChainOutput{
+               Source:         source,
+               ControlProgram: controlProgram,
+               Ordinal:        ordinal,
+       }
+}