core: treat state.Coin as a bitfield

As it was intended to.
This commit is contained in:
Roman Khimov 2020-03-09 17:18:04 +03:00
parent 377fb382aa
commit e1f194ea7b
2 changed files with 2 additions and 2 deletions

View file

@ -501,7 +501,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
}
oldSpentCoinLen := len(spentCoin.Items)
for _, input := range inputs {
unspent.States[input.PrevIndex] = state.CoinSpent
unspent.States[input.PrevIndex] |= state.CoinSpent
prevTXOutput := prevTX.Outputs[input.PrevIndex]
account, err := cache.GetAccountStateOrNew(prevTXOutput.ScriptHash)
if err != nil {

View file

@ -590,7 +590,7 @@ func (dao *dao) IsDoubleSpend(tx *transaction.Transaction) bool {
return false
}
for _, input := range inputs {
if int(input.PrevIndex) >= len(unspent.States) || unspent.States[input.PrevIndex] == state.CoinSpent {
if int(input.PrevIndex) >= len(unspent.States) || (unspent.States[input.PrevIndex]&state.CoinSpent) != 0 {
return true
}
}