aboutsummaryrefslogtreecommitdiff
path: root/pkg/blockchain/coindatabase/coin.go
diff options
context:
space:
mode:
authorgithub-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com>2022-02-28 19:36:23 +0000
committergithub-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com>2022-02-28 19:36:23 +0000
commit1dd0508d5d3c737f1ee9c723f580baf73b1cfd70 (patch)
tree6adcc5ef85f9cf0bbb205c577da0bac9148114dd /pkg/blockchain/coindatabase/coin.go
Initial commit
Diffstat (limited to 'pkg/blockchain/coindatabase/coin.go')
-rw-r--r--pkg/blockchain/coindatabase/coin.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkg/blockchain/coindatabase/coin.go b/pkg/blockchain/coindatabase/coin.go
new file mode 100644
index 0000000..4281ac1
--- /dev/null
+++ b/pkg/blockchain/coindatabase/coin.go
@@ -0,0 +1,29 @@
+package coindatabase
+
+import "Chain/pkg/block"
+
+// Coin is used by the CoinDatabase to keep track of unspent
+// TransactionOutputs.
+// TransactionOutput is the underlying TransactionOutput.
+// IsSpent is whether that TransactionOutput has been spent.
+// Active is whether that TransactionOutput is one created by
+// Blocks on the active Chain.
+type Coin struct {
+ TransactionOutput *block.TransactionOutput
+ IsSpent bool
+}
+
+// CoinLocator is a dumbed down TransactionInput, used
+// as a key to Coins in the CoinDatabase's mainCache.
+type CoinLocator struct {
+ ReferenceTransactionHash string
+ OutputIndex uint32
+}
+
+// makeCoinLocator returns a CoinLocator given a TransactionInput.
+func makeCoinLocator(txi *block.TransactionInput) CoinLocator {
+ return CoinLocator{
+ ReferenceTransactionHash: txi.ReferenceTransactionHash,
+ OutputIndex: txi.OutputIndex,
+ }
+}