use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class BatchEntityListenerTest method topicMessage.
protected TopicMessage topicMessage() {
TopicMessage topicMessage = new TopicMessage();
topicMessage.setChunkNum(1);
topicMessage.setChunkTotal(2);
topicMessage.setConsensusTimestamp(consensusTimestamp++);
topicMessage.setMessage("test message".getBytes());
topicMessage.setPayerAccountId(EntityId.of("0.1.1000", EntityType.ACCOUNT));
topicMessage.setRunningHash("running hash".getBytes());
topicMessage.setRunningHashVersion(2);
topicMessage.setSequenceNumber(sequenceNumber++);
topicMessage.setTopicId(EntityId.of("0.0.101", EntityType.TOPIC));
topicMessage.setValidStartTimestamp(4L);
return topicMessage;
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class RedisEntityListener method callback.
// Batch send using Redis pipelining
private SessionCallback<Object> callback(List<TopicMessage> messages) {
return new SessionCallback<>() {
@Override
public Object execute(RedisOperations operations) {
for (TopicMessage topicMessage : messages) {
String channel = channelNames.get(topicMessage.getTopicId().getId());
redisOperations.convertAndSend(channel, topicMessage);
}
return null;
}
};
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class BatchInserterTest method topicMessage.
private TopicMessage topicMessage(long consensusNs, int messageSize) {
TopicMessage topicMessage = new TopicMessage();
topicMessage.setConsensusTimestamp(consensusNs);
topicMessage.setPayerAccountId(EntityId.of("0.0.1002", ACCOUNT));
// Just exceeds 8000B
topicMessage.setMessage(RandomUtils.nextBytes(messageSize));
topicMessage.setRunningHash(Strings.toByteArray("running hash"));
topicMessage.setRunningHashVersion(2);
topicMessage.setSequenceNumber(consensusNs);
topicMessage.setTopicId(EntityId.of("0.0.1001", EntityType.TOPIC));
return topicMessage;
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertConsensusTopicMessage.
private void insertConsensusTopicMessage(RecordItem recordItem) {
if (!entityProperties.getPersist().isTopics()) {
return;
}
ConsensusSubmitMessageTransactionBody transactionBody = recordItem.getTransactionBody().getConsensusSubmitMessage();
TransactionRecord transactionRecord = recordItem.getRecord();
var receipt = transactionRecord.getReceipt();
var topicId = transactionBody.getTopicID();
int runningHashVersion = receipt.getTopicRunningHashVersion() == 0 ? 1 : (int) receipt.getTopicRunningHashVersion();
TopicMessage topicMessage = new TopicMessage();
// Handle optional fragmented topic message
if (transactionBody.hasChunkInfo()) {
ConsensusMessageChunkInfo chunkInfo = transactionBody.getChunkInfo();
topicMessage.setChunkNum(chunkInfo.getNumber());
topicMessage.setChunkTotal(chunkInfo.getTotal());
if (chunkInfo.hasInitialTransactionID()) {
topicMessage.setInitialTransactionId(chunkInfo.getInitialTransactionID().toByteArray());
}
}
topicMessage.setConsensusTimestamp(DomainUtils.timeStampInNanos(transactionRecord.getConsensusTimestamp()));
topicMessage.setMessage(DomainUtils.toBytes(transactionBody.getMessage()));
topicMessage.setPayerAccountId(recordItem.getPayerAccountId());
topicMessage.setRunningHash(DomainUtils.toBytes(receipt.getTopicRunningHash()));
topicMessage.setRunningHashVersion(runningHashVersion);
topicMessage.setSequenceNumber(receipt.getTopicSequenceNumber());
topicMessage.setTopicId(EntityId.of(topicId));
entityListener.onTopicMessage(topicMessage);
}
use of com.hedera.mirror.common.domain.topic.TopicMessage in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method getTopicMessage.
private TopicMessage getTopicMessage() {
TopicMessage topicMessage = new TopicMessage();
topicMessage.setChunkNum(1);
topicMessage.setChunkTotal(2);
topicMessage.setConsensusTimestamp(1L);
topicMessage.setMessage("test message".getBytes());
topicMessage.setPayerAccountId(EntityId.of("0.1.1000", EntityType.ACCOUNT));
topicMessage.setRunningHash("running hash".getBytes());
topicMessage.setRunningHashVersion(2);
topicMessage.setSequenceNumber(1L);
topicMessage.setTopicId(EntityId.of("0.0.1001", EntityType.TOPIC));
topicMessage.setValidStartTimestamp(4L);
return topicMessage;
}
Aggregations