From 394346fc26e465f018bd410fdf405364adbe6b84 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 11 Nov 2019 15:35:57 +0300 Subject: [PATCH] core: add proper claim transactions processing --- pkg/core/blockchain.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 9d04377fa..77ae2e8fa 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -431,6 +431,21 @@ func (bc *Blockchain) storeBlock(block *Block) error { } } case *transaction.ClaimTX: + // Remove claimed NEO from spent coins making it unavalaible for + // additional claims. + for _, input := range t.Claims { + scs, err := spentCoins.getAndUpdate(bc.store, input.PrevHash) + if err != nil { + return err + } + if scs.txHash == input.PrevHash { + // Existing scs. + delete(scs.items, input.PrevIndex) + } else { + // Uninitialized, new, forget about it. + delete(spentCoins, input.PrevHash) + } + } case *transaction.EnrollmentTX: case *transaction.StateTX: case *transaction.PublishTX: