mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
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:
parent
36c6b6af14
commit
c258adb532
3 changed files with 36 additions and 16 deletions
|
@ -175,15 +175,13 @@ func (dao *dao) PutUnspentCoinState(hash util.Uint256, ucs *UnspentCoinState) er
|
|||
// -- start spent coins.
|
||||
|
||||
// GetSpentCoinsOrNew returns spent coins from store.
|
||||
func (dao *dao) GetSpentCoinsOrNew(hash util.Uint256) (*SpentCoinState, error) {
|
||||
func (dao *dao) GetSpentCoinsOrNew(hash util.Uint256, height uint32) (*SpentCoinState, error) {
|
||||
spent, err := dao.GetSpentCoinState(hash)
|
||||
if err != nil {
|
||||
if err != storage.ErrKeyNotFound {
|
||||
return nil, err
|
||||
}
|
||||
spent = &SpentCoinState{
|
||||
items: make(map[uint16]uint32),
|
||||
}
|
||||
spent = NewSpentCoinState(hash, height)
|
||||
}
|
||||
return spent, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue