void addToAssetBalanceQNT(long assetId, long quantityQNT) { if (quantityQNT == 0) { return; } AccountAsset accountAsset; accountAsset = accountAssetTable.get(accountAssetDbKeyFactory.newKey(this.id, assetId)); long assetBalance = accountAsset == null ? 0 : accountAsset.quantityQNT; assetBalance = Convert.safeAdd(assetBalance, quantityQNT); if (accountAsset == null) { accountAsset = new AccountAsset(this.id, assetId, assetBalance, 0); } else { accountAsset.quantityQNT = assetBalance; } accountAsset.save(); listeners.notify(this, Event.ASSET_BALANCE); assetListeners.notify(accountAsset, Event.ASSET_BALANCE); }
void addToUnconfirmedAssetBalanceQNT(long assetId, long quantityQNT) { if (quantityQNT == 0) { return; } AccountAsset accountAsset; accountAsset = accountAssetTable.get(accountAssetDbKeyFactory.newKey(this.id, assetId)); long unconfirmedAssetBalance = accountAsset == null ? 0 : accountAsset.unconfirmedQuantityQNT; unconfirmedAssetBalance = Convert.safeAdd(unconfirmedAssetBalance, quantityQNT); if (accountAsset == null) { accountAsset = new AccountAsset(this.id, assetId, 0, unconfirmedAssetBalance); } else { accountAsset.unconfirmedQuantityQNT = unconfirmedAssetBalance; } accountAsset.save(); listeners.notify(this, Event.UNCONFIRMED_ASSET_BALANCE); assetListeners.notify(accountAsset, Event.UNCONFIRMED_ASSET_BALANCE); }
public long getUnconfirmedAssetBalanceQNT(long assetId) { AccountAsset accountAsset = accountAssetTable.get(accountAssetDbKeyFactory.newKey(this.id, assetId)); return accountAsset == null ? 0 : accountAsset.unconfirmedQuantityQNT; }