From 917e0f89dd82639f8a9709484f4e4c582138b689 Mon Sep 17 00:00:00 2001 From: Hans Moog <3293976+hmoog@users.noreply.github.com> Date: Thu, 10 Mar 2022 14:42:23 +0100 Subject: [PATCH] Feat: Realities Ledger Rework This PR adds the following features: - solidification - multithreading - pluggable VMs --- packages/utxo/input.go | 4 ++++ packages/utxo/output.go | 5 +++++ packages/utxo/outputid.go | 3 +++ packages/utxo/transaction.go | 9 +++++++++ packages/utxo/transactionid.go | 18 ++++++++++++++++++ packages/utxo/vm.go | 1 + 6 files changed, 40 insertions(+) create mode 100644 packages/utxo/input.go create mode 100644 packages/utxo/output.go create mode 100644 packages/utxo/outputid.go create mode 100644 packages/utxo/transaction.go create mode 100644 packages/utxo/transactionid.go create mode 100644 packages/utxo/vm.go diff --git a/packages/utxo/input.go b/packages/utxo/input.go new file mode 100644 index 0000000000..1293d3d6f1 --- /dev/null +++ b/packages/utxo/input.go @@ -0,0 +1,4 @@ +package utxo + +type Input interface { +} diff --git a/packages/utxo/output.go b/packages/utxo/output.go new file mode 100644 index 0000000000..d95f6890f4 --- /dev/null +++ b/packages/utxo/output.go @@ -0,0 +1,5 @@ +package utxo + +type Output interface { + ID() OutputID +} diff --git a/packages/utxo/outputid.go b/packages/utxo/outputid.go new file mode 100644 index 0000000000..3f8da4ad0e --- /dev/null +++ b/packages/utxo/outputid.go @@ -0,0 +1,3 @@ +package utxo + +type OutputID [32]byte diff --git a/packages/utxo/transaction.go b/packages/utxo/transaction.go new file mode 100644 index 0000000000..eb6f1da348 --- /dev/null +++ b/packages/utxo/transaction.go @@ -0,0 +1,9 @@ +package utxo + +type Transaction interface { + ID() TransactionID + + Inputs() []Input + + Bytes() []byte +} diff --git a/packages/utxo/transactionid.go b/packages/utxo/transactionid.go new file mode 100644 index 0000000000..9a49c04ed9 --- /dev/null +++ b/packages/utxo/transactionid.go @@ -0,0 +1,18 @@ +package utxo + +import ( + "github.com/mr-tron/base58" +) + +// TransactionID is the type that represents the identifier of a Transaction. +type TransactionID [32]byte + +// Bytes returns a marshaled version of the TransactionID. +func (t TransactionID) Bytes() (serializedTransaction []byte) { + return t[:] +} + +// String creates a human-readable version of the TransactionID. +func (t TransactionID) String() (humanReadableTransactionID string) { + return "TransactionID(" + base58.Encode(t[:]) + ")" +} diff --git a/packages/utxo/vm.go b/packages/utxo/vm.go new file mode 100644 index 0000000000..91279cacf2 --- /dev/null +++ b/packages/utxo/vm.go @@ -0,0 +1 @@ +package utxo