diff options
Diffstat (limited to 'pkg/blockchain/coindatabase/coin.go')
-rw-r--r-- | pkg/blockchain/coindatabase/coin.go | 29 |
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, + } +} |