Skip to content

Commit

Permalink
reorganize how delete records works
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Dec 1, 2020
1 parent 0f06e03 commit 3f78cab
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions storage/modules/balance_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,7 @@ func (b *BalanceStorage) SetBalance(
amount *types.Amount,
block *types.BlockIdentifier,
) error {
// Remove all historical records
if err := b.removeHistoricalBalances(
ctx,
dbTransaction,
account,
amount.Currency,
-1,
true, // We want everything >= -1
); err != nil {
return err
}

// Remove all account keys
// Remove all account-related items
if err := b.deleteAccountRecords(
ctx,
dbTransaction,
Expand Down Expand Up @@ -647,6 +635,19 @@ func (b *BalanceStorage) deleteAccountRecords(
account *types.AccountIdentifier,
currency *types.Currency,
) error {
// Remove historical balance records
if err := b.removeHistoricalBalances(
ctx,
dbTx,
account,
currency,
-1,
true, // We want everything >= -1
); err != nil {
return err
}

// Remove single key records
for _, namespace := range []string{
accountNamespace,
reconciliationNamepace,
Expand Down

0 comments on commit 3f78cab

Please sign in to comment.