Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ledger/appcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ func (cb *roundCowState) AllocateApp(addr basics.Address, aidx basics.AppIndex,
Creator: addr,
Created: true,
}
} else {
aa := ledgercore.AccountApp{
Address: addr,
App: aidx,
}
cb.mods.ModifiedAppLocalStates[aa] = true
}

cb.trackCreatable(basics.CreatableIndex(aidx))
Expand Down Expand Up @@ -282,6 +288,12 @@ func (cb *roundCowState) DeallocateApp(addr basics.Address, aidx basics.AppIndex
Creator: addr,
Created: false,
}
} else {
aa := ledgercore.AccountApp{
Address: addr,
App: aidx,
}
cb.mods.ModifiedAppLocalStates[aa] = false
}

return nil
Expand Down
20 changes: 19 additions & 1 deletion ledger/apply/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
}

// Tell the cow what asset we created
return balances.AllocateAsset(header.Sender, newidx, true)
err = balances.AllocateAsset(header.Sender, newidx, true)
if err != nil {
return err
}
return balances.AllocateAsset(header.Sender, newidx, false)
}

// Re-configuration and destroying must be done by the manager key.
Expand Down Expand Up @@ -134,6 +138,10 @@ func AssetConfig(cc transactions.AssetConfigTxnFields, header transactions.Heade
if err != nil {
return err
}
err = balances.DeallocateAsset(creator, cc.ConfigAsset, false)
if err != nil {
return err
}
Comment on lines +141 to +144
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double call does not look good, how about adding bit flags specifying global or local, or both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with double call? Asset params and asset holdings are modified separately in account data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Balance interface is simpler as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling twice is a clear indication that the interface is wrong.. I'd agree with Pavel that we should update the function call.


delete(record.Assets, cc.ConfigAsset)
delete(record.AssetParams, cc.ConfigAsset)
Expand Down Expand Up @@ -269,6 +277,11 @@ func AssetTransfer(ct transactions.AssetTransferTxnFields, header transactions.H
if err != nil {
return err
}

err = balances.AllocateAsset(source, ct.XferAsset, false)
if err != nil {
return err
}
}
}

Expand Down Expand Up @@ -363,6 +376,11 @@ func AssetTransfer(ct transactions.AssetTransferTxnFields, header transactions.H
if err != nil {
return err
}

err = balances.DeallocateAsset(source, ct.XferAsset, false)
if err != nil {
return err
}
}

return nil
Expand Down
12 changes: 12 additions & 0 deletions ledger/assetcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func (cs *roundCowState) AllocateAsset(addr basics.Address, index basics.AssetIn
}

cs.trackCreatable(basics.CreatableIndex(index))
} else {
aa := ledgercore.AccountAsset{
Address: addr,
Asset: index,
}
cs.mods.ModifiedAssetHoldings[aa] = true
}

return nil
Expand All @@ -42,6 +48,12 @@ func (cs *roundCowState) DeallocateAsset(addr basics.Address, index basics.Asset
Creator: addr,
Created: false,
}
} else {
aa := ledgercore.AccountAsset{
Address: addr,
Asset: index,
}
cs.mods.ModifiedAssetHoldings[aa] = false
}

return nil
Expand Down
6 changes: 6 additions & 0 deletions ledger/cow.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ func (cb *roundCowState) commitToParent() {
}
}
cb.commitParent.mods.CompactCertNext = cb.mods.CompactCertNext
for index, created := range cb.mods.ModifiedAssetHoldings {
cb.commitParent.mods.ModifiedAssetHoldings[index] = created
}
for index, created := range cb.mods.ModifiedAppLocalStates {
cb.commitParent.mods.ModifiedAppLocalStates[index] = created
}
}

func (cb *roundCowState) modifiedAccounts() []basics.Address {
Expand Down
Loading