core: add issue tx processing
Count available asset quantity, match C# code.
This commit is contained in:
parent
2611e9ab5c
commit
99bbad331d
1 changed files with 15 additions and 0 deletions
|
@ -394,6 +394,21 @@ func (bc *Blockchain) storeBlock(block *Block) error {
|
||||||
Expiration: bc.BlockHeight() + registeredAssetLifetime,
|
Expiration: bc.BlockHeight() + registeredAssetLifetime,
|
||||||
}
|
}
|
||||||
case *transaction.IssueTX:
|
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.ClaimTX:
|
||||||
case *transaction.EnrollmentTX:
|
case *transaction.EnrollmentTX:
|
||||||
case *transaction.StateTX:
|
case *transaction.StateTX:
|
||||||
|
|
Loading…
Reference in a new issue