use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertStakingRewardTransfers.
private void insertStakingRewardTransfers(RecordItem recordItem) {
var consensusTimestamp = recordItem.getConsensusTimestamp();
var payerAccountId = recordItem.getPayerAccountId();
for (var aa : recordItem.getRecord().getPaidStakingRewardsList()) {
var accountId = EntityId.of(aa.getAccountID());
var stakingRewardTransfer = new StakingRewardTransfer();
stakingRewardTransfer.setAccountId(accountId.getId());
stakingRewardTransfer.setAmount(aa.getAmount());
stakingRewardTransfer.setConsensusTimestamp(consensusTimestamp);
stakingRewardTransfer.setPayerAccountId(payerAccountId);
entityListener.onStakingRewardTransfer(stakingRewardTransfer);
// The staking reward may be paid to either an account or a contract. Create non-history updates
// with the new stake reward start for both an account entity and a contract, the upsert sql
// will only update one depending on the actual type of the entity.
Entity account = accountId.toEntity();
var stakePeriodStart = Utility.getEpochDay(consensusTimestamp);
account.setStakePeriodStart(stakePeriodStart);
// Don't trigger a history row
account.setTimestampRange(null);
entityListener.onEntity(account);
Contract contract = EntityId.of(account.getShard(), account.getRealm(), account.getNum(), EntityType.CONTRACT).toEntity();
contract.setStakePeriodStart(stakePeriodStart);
// Don't trigger a history row
contract.setTimestampRange(null);
entityListener.onContract(contract);
}
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class SqlEntityListener method onEntity.
@Override
public void onEntity(Entity entity) throws ImporterException {
long id = entity.getId();
if (id == EntityId.EMPTY.getId()) {
return;
}
Entity merged = entityState.merge(entity.getId(), entity, this::mergeEntity);
if (merged == entity) {
// only add the merged object to the collection if the state is replaced with the new entity object, i.e.,
// attributes only in the previous state are merged into the new entity object
entities.add(entity);
}
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method storeAccountDeleted.
@Test
void storeAccountDeleted() {
Entity account = domainBuilder.entity().customize(e -> e.deleted(true)).get();
entityIdService.notify(account);
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(getProtoAccountId(account)));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupAccountAlias.
@Test
void lookupAccountAlias() {
Entity account = domainBuilder.entity().persist();
assertThat(entityIdService.lookup(getProtoAccountId(account))).isEqualTo(account.toEntityId());
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method storeAccount.
@ParameterizedTest
@CsvSource(value = { "false", "," })
void storeAccount(Boolean deleted) {
Entity account = domainBuilder.entity().customize(e -> e.deleted(deleted)).get();
entityIdService.notify(account);
assertThat(entityIdService.lookup(getProtoAccountId(account))).isEqualTo(account.toEntityId());
}
Aggregations