From 19fd7f844ebc230431b115f9b6fc57bc562855ff Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 11 Oct 2019 14:16:53 +0300 Subject: [PATCH] core: add GetUnspentCoinState() for future interops --- pkg/core/blockchain.go | 9 +++++++++ pkg/core/blockchainer.go | 1 + pkg/network/helper_test.go | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index d8051e9c0..ac37762ba 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -740,6 +740,15 @@ func (bc *Blockchain) GetAccountState(scriptHash util.Uint160) *AccountState { return as } +// GetUnspentCoinState returns unspent coin state for given tx hash. +func (bc *Blockchain) GetUnspentCoinState(hash util.Uint256) *UnspentCoinState { + ucs, err := getUnspentCoinStateFromStore(bc.memStore, hash) + if err != nil { + ucs, _ = getUnspentCoinStateFromStore(bc.Store, hash) + } + return ucs +} + // GetConfig returns the config stored in the blockchain func (bc *Blockchain) GetConfig() config.ProtocolConfiguration { return bc.config diff --git a/pkg/core/blockchainer.go b/pkg/core/blockchainer.go index 85724a4cd..7038617b1 100644 --- a/pkg/core/blockchainer.go +++ b/pkg/core/blockchainer.go @@ -26,6 +26,7 @@ type Blockchainer interface { GetStorageItem(scripthash util.Uint160, key []byte) *StorageItem GetStorageItems(hash util.Uint160) (map[string]*StorageItem, error) GetTransaction(util.Uint256) (*transaction.Transaction, uint32, error) + GetUnspentCoinState(util.Uint256) *UnspentCoinState References(t *transaction.Transaction) map[transaction.Input]*transaction.Output Feer // fee interface Verify(t *transaction.Transaction) error diff --git a/pkg/network/helper_test.go b/pkg/network/helper_test.go index 0aeec48d9..1b851b226 100644 --- a/pkg/network/helper_test.go +++ b/pkg/network/helper_test.go @@ -91,6 +91,10 @@ func (chain testChain) GetTransaction(util.Uint256) (*transaction.Transaction, u panic("TODO") } +func (chain testChain) GetUnspentCoinState(util.Uint256) *core.UnspentCoinState { + panic("TODO") +} + func (chain testChain) GetMemPool() core.MemPool { panic("TODO") }