static Account addOrGetAccount(long id) { Account account = accountTable.get(accountDbKeyFactory.newKey(id)); if (account == null) { account = new Account(id); accountTable.insert(account); } return account; }
public static Account getAccount(byte[] publicKey) { Account account = accountTable.get(accountDbKeyFactory.newKey(getId(publicKey))); if (account == null) { return null; } if (account.getPublicKey() == null || Arrays.equals(account.getPublicKey(), publicKey)) { return account; } throw new RuntimeException( "DUPLICATE KEY for account " + Convert.toUnsignedLong(account.getId()) + " existing key " + Convert.toHexString(account.getPublicKey()) + " new key " + Convert.toHexString(publicKey)); }
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); }
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); }
public static RewardRecipientAssignment getRewardRecipientAssignment(Long id) { return rewardRecipientAssignmentTable.get(rewardRecipientAssignmentDbKeyFactory.newKey(id)); }
public long getUnconfirmedAssetBalanceQNT(long assetId) { AccountAsset accountAsset = accountAssetTable.get(accountAssetDbKeyFactory.newKey(this.id, assetId)); return accountAsset == null ? 0 : accountAsset.unconfirmedQuantityQNT; }
public static Account getAccount(long id, int height) { return id == 0 ? null : accountTable.get(accountDbKeyFactory.newKey(id), height); }