use of com.hedera.mirror.importer.domain.TransactionFilterFields in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method onItem.
@Override
public void onItem(RecordItem recordItem) throws ImporterException {
TransactionRecord txRecord = recordItem.getRecord();
TransactionBody body = recordItem.getTransactionBody();
int transactionTypeValue = recordItem.getTransactionType();
TransactionType transactionType = TransactionType.of(transactionTypeValue);
TransactionHandler transactionHandler = transactionHandlerFactory.get(transactionType);
long consensusTimestamp = DomainUtils.timeStampInNanos(txRecord.getConsensusTimestamp());
EntityId entityId;
try {
entityId = transactionHandler.getEntity(recordItem);
} catch (InvalidEntityException e) {
// transaction can have invalid topic/contract/file id
log.warn("Invalid entity encountered for consensusTimestamp {} : {}", consensusTimestamp, e.getMessage());
entityId = null;
}
log.debug("Processing {} transaction {} for entity {}", transactionType, consensusTimestamp, entityId);
// to:do - exclude Freeze from Filter transaction type
TransactionFilterFields transactionFilterFields = new TransactionFilterFields(entityId, transactionType);
if (!transactionFilter.test(transactionFilterFields)) {
log.debug("Ignoring transaction. consensusTimestamp={}, transactionType={}, entityId={}", consensusTimestamp, transactionType, entityId);
return;
}
Transaction transaction = buildTransaction(consensusTimestamp, recordItem);
transaction.setEntityId(entityId);
transactionHandler.updateTransaction(transaction, recordItem);
if (txRecord.hasTransferList() && entityProperties.getPersist().isCryptoTransferAmounts()) {
insertTransferList(recordItem);
}
// insert staking reward transfers even on failure
insertStakingRewardTransfers(recordItem);
// handle scheduled transaction, even on failure
if (transaction.isScheduled()) {
onScheduledTransaction(recordItem);
}
if (recordItem.isSuccessful()) {
if (entityProperties.getPersist().getTransactionSignatures().contains(transactionType)) {
insertTransactionSignatures(transaction.getEntityId(), recordItem.getConsensusTimestamp(), recordItem.getSignatureMap().getSigPairList());
}
// Only add non-fee transfers on success as the data is assured to be valid
processNonFeeTransfers(consensusTimestamp, recordItem);
if (body.hasConsensusSubmitMessage()) {
insertConsensusTopicMessage(recordItem);
} else if (body.hasCryptoAddLiveHash()) {
insertCryptoAddLiveHash(consensusTimestamp, body.getCryptoAddLiveHash());
} else if (body.hasFileAppend()) {
insertFileAppend(consensusTimestamp, body.getFileAppend(), transactionTypeValue);
} else if (body.hasFileCreate()) {
insertFileData(consensusTimestamp, DomainUtils.toBytes(body.getFileCreate().getContents()), txRecord.getReceipt().getFileID(), transactionTypeValue);
} else if (body.hasFileUpdate()) {
insertFileUpdate(consensusTimestamp, body.getFileUpdate(), transactionTypeValue);
} else if (body.hasTokenAssociate()) {
insertTokenAssociate(recordItem);
} else if (body.hasTokenBurn()) {
insertTokenBurn(recordItem);
} else if (body.hasTokenCreation()) {
insertTokenCreate(recordItem);
} else if (body.hasTokenDissociate()) {
insertTokenDissociate(recordItem);
} else if (body.hasTokenFeeScheduleUpdate()) {
insertTokenFeeScheduleUpdate(recordItem);
} else if (body.hasTokenFreeze()) {
insertTokenAccountFreezeBody(recordItem);
} else if (body.hasTokenGrantKyc()) {
insertTokenAccountGrantKyc(recordItem);
} else if (body.hasTokenMint()) {
insertTokenMint(recordItem);
} else if (body.hasTokenPause()) {
insertTokenPause(recordItem);
} else if (body.hasTokenRevokeKyc()) {
insertTokenAccountRevokeKyc(recordItem);
} else if (body.hasTokenUnfreeze()) {
insertTokenAccountUnfreeze(recordItem);
} else if (body.hasTokenUnpause()) {
insertTokenUnpause(recordItem);
} else if (body.hasTokenUpdate()) {
insertTokenUpdate(recordItem);
} else if (body.hasTokenWipe()) {
insertTokenAccountWipe(recordItem);
}
// Record token transfers can be populated for multiple transaction types
insertTokenTransfers(recordItem);
insertAssessedCustomFees(recordItem);
insertAutomaticTokenAssociations(recordItem);
}
contractResultService.process(recordItem, transaction);
entityListener.onTransaction(transaction);
log.debug("Storing transaction: {}", transaction);
}
Aggregations