From e1f194ea7b8f8c6a49d647869b2c709c57634e69 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 9 Mar 2020 17:18:04 +0300 Subject: [PATCH] core: treat state.Coin as a bitfield As it was intended to. --- pkg/core/blockchain.go | 2 +- pkg/core/dao.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index d7bfc42e2..23f2610cc 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -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 { diff --git a/pkg/core/dao.go b/pkg/core/dao.go index fbab4c6ef..f211a2d42 100644 --- a/pkg/core/dao.go +++ b/pkg/core/dao.go @@ -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 } }