core: move spent coin management out of the inner storeBlock loop

prevHash == input.PrevHash, so make less DB accesses and more real work. Fix
some bugs along the way:
 * spentCoins structure may already be present in the DB when persisting TX,
   there is nothing wrong with that and we shouldn't overwrite it
 * it's only used for NEO and only to check for claim validity. Thus, when
   processing claim tx the corresponding spentCoins should always be present
   in the DB
This commit is contained in:
Roman Khimov 2020-02-24 19:05:55 +03:00
parent 36c6b6af14
commit c258adb532
3 changed files with 36 additions and 16 deletions

View file

@ -124,7 +124,7 @@ func TestPutGetUnspentCoinState(t *testing.T) {
func TestGetSpentCoinStateOrNew_New(t *testing.T) {
dao := newDao(storage.NewMemoryStore())
hash := random.Uint256()
spentCoinState, err := dao.GetSpentCoinsOrNew(hash)
spentCoinState, err := dao.GetSpentCoinsOrNew(hash, 1)
require.NoError(t, err)
require.NotNil(t, spentCoinState)
}