summaryrefslogtreecommitdiff
path: root/ledger/internal/assetcow.go
diff options
context:
space:
mode:
Diffstat (limited to 'ledger/internal/assetcow.go')
-rw-r--r--ledger/internal/assetcow.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/ledger/internal/assetcow.go b/ledger/internal/assetcow.go
new file mode 100644
index 000000000..b28d09a7f
--- /dev/null
+++ b/ledger/internal/assetcow.go
@@ -0,0 +1,60 @@
+// Copyright (C) 2019-2021 Algorand, Inc.
+// This file is part of go-algorand
+//
+// go-algorand is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// go-algorand is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.
+
+package internal
+
+import (
+ "github.com/algorand/go-algorand/data/basics"
+ "github.com/algorand/go-algorand/ledger/ledgercore"
+)
+
+func (cs *roundCowState) AllocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ cs.mods.Creatables[basics.CreatableIndex(index)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AssetCreatable,
+ Creator: addr,
+ Created: true,
+ }
+
+ cs.trackCreatable(basics.CreatableIndex(index))
+ } else {
+ aa := ledgercore.AccountAsset{
+ Address: addr,
+ Asset: index,
+ }
+ cs.mods.ModifiedAssetHoldings[aa] = true
+ }
+
+ return nil
+}
+
+func (cs *roundCowState) DeallocateAsset(addr basics.Address, index basics.AssetIndex, global bool) error {
+ if global {
+ cs.mods.Creatables[basics.CreatableIndex(index)] = ledgercore.ModifiedCreatable{
+ Ctype: basics.AssetCreatable,
+ Creator: addr,
+ Created: false,
+ }
+ } else {
+ aa := ledgercore.AccountAsset{
+ Address: addr,
+ Asset: index,
+ }
+ cs.mods.ModifiedAssetHoldings[aa] = false
+ }
+
+ return nil
+}