Пример #1
0
 static Account addOrGetAccount(long id) {
   Account account = accountTable.get(accountDbKeyFactory.newKey(id));
   if (account == null) {
     account = new Account(id);
     accountTable.insert(account);
   }
   return account;
 }
Пример #2
0
 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));
 }
Пример #3
0
 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);
 }
Пример #4
0
 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);
 }
Пример #5
0
 public static RewardRecipientAssignment getRewardRecipientAssignment(Long id) {
   return rewardRecipientAssignmentTable.get(rewardRecipientAssignmentDbKeyFactory.newKey(id));
 }
Пример #6
0
 public long getUnconfirmedAssetBalanceQNT(long assetId) {
   AccountAsset accountAsset =
       accountAssetTable.get(accountAssetDbKeyFactory.newKey(this.id, assetId));
   return accountAsset == null ? 0 : accountAsset.unconfirmedQuantityQNT;
 }
Пример #7
0
 public static Account getAccount(long id, int height) {
   return id == 0 ? null : accountTable.get(accountDbKeyFactory.newKey(id), height);
 }