From 99bbad331d2823901f15510be6e918e793a78932 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 25 Oct 2019 17:20:12 +0300 Subject: [PATCH] core: add issue tx processing Count available asset quantity, match C# code. --- pkg/core/blockchain.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 13159122e..f29aaaeda 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -394,6 +394,21 @@ func (bc *Blockchain) storeBlock(block *Block) error { Expiration: bc.BlockHeight() + registeredAssetLifetime, } case *transaction.IssueTX: + for _, res := range bc.GetTransactionResults(tx) { + if res.Amount < 0 { + var asset *AssetState + + asset, ok := assets[res.AssetID] + if !ok { + asset = bc.GetAssetState(res.AssetID) + } + if asset == nil { + return fmt.Errorf("issue failed: no asset %s", res.AssetID) + } + asset.Available -= res.Amount + assets[res.AssetID] = asset + } + } case *transaction.ClaimTX: case *transaction.EnrollmentTX: case *transaction.StateTX: