forked from Qortal/qortal
Combined account balance fixes needed for unit tests
This commit is contained in:
parent
48de33fe24
commit
136188339d
@ -77,6 +77,12 @@ public class Account {
|
||||
throw new DataException(message);
|
||||
}
|
||||
|
||||
// Delete account balance record instead of setting balance to zero
|
||||
if (balance.signum() == 0) {
|
||||
this.repository.getAccountRepository().delete(this.address, assetId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't have a balance without an account - make sure it exists!
|
||||
this.repository.getAccountRepository().ensureAccount(this.buildAccountData());
|
||||
|
||||
|
@ -250,8 +250,10 @@ public class Payment {
|
||||
* For QORT amounts only: If recipient's last reference is this transaction's signature, then they can't have made any transactions of their own
|
||||
* (which would have changed their last reference) thus this is their first reference so remove it.
|
||||
*/
|
||||
if ((alwaysUninitializeRecipientReference || assetId == Asset.QORT) && Arrays.equals(recipient.getLastReference(), signature))
|
||||
if ((alwaysUninitializeRecipientReference || assetId == Asset.QORT) && Arrays.equals(recipient.getLastReference(), signature)) {
|
||||
recipient.setLastReference(null);
|
||||
this.repository.getAccountRepository().delete(recipient.getAddress(), assetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,6 +188,9 @@ public class HSQLDBAssetRepository implements AssetRepository {
|
||||
public void delete(long assetId) throws DataException {
|
||||
try {
|
||||
this.repository.delete("Assets", "asset_id = ?", assetId);
|
||||
|
||||
// Also delete account balances that refer to asset
|
||||
this.repository.delete("AccountBalances", "asset_id = ?", assetId);
|
||||
} catch (SQLException e) {
|
||||
throw new DataException("Unable to delete asset from repository", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user