use of com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo in project hedera-services by hashgraph.
the class SubmitMessageTransitionLogicTest method givenChunkMessage.
private void givenChunkMessage(int totalChunks, int chunkNumber, TransactionID initialTransactionID) {
ConsensusMessageChunkInfo chunkInfo = ConsensusMessageChunkInfo.newBuilder().setInitialTransactionID(initialTransactionID).setTotal(totalChunks).setNumber(chunkNumber).build();
givenTransaction(getBasicValidTransactionBodyBuilder().setChunkInfo(chunkInfo));
given(validator.queryableTopicStatus(asTopic(TOPIC_ID), topics)).willReturn(OK);
topics.put(EntityNum.fromTopicId(asTopic(TOPIC_ID)), new MerkleTopic());
}
use of com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo 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.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo in project hedera-services by hashgraph.
the class HapiMessageSubmit method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
TopicID id = resolveTopicId(spec);
ConsensusSubmitMessageTransactionBody opBody = spec.txns().<ConsensusSubmitMessageTransactionBody, ConsensusSubmitMessageTransactionBody.Builder>body(ConsensusSubmitMessageTransactionBody.class, b -> {
b.setTopicID(id);
message.ifPresent(m -> b.setMessage(m));
if (clearMessage) {
b.clearMessage();
}
if (totalChunks.isPresent() && chunkNumber.isPresent()) {
ConsensusMessageChunkInfo chunkInfo = ConsensusMessageChunkInfo.newBuilder().setInitialTransactionID(initialTransactionID.orElse(asTransactionID(spec, initialTransactionPayer.isPresent() ? initialTransactionPayer : payer))).setTotal(totalChunks.getAsInt()).setNumber(chunkNumber.getAsInt()).build();
b.setChunkInfo(chunkInfo);
spec.registry().saveTimestamp(txnName, chunkInfo.getInitialTransactionID().getTransactionValidStart());
}
});
return b -> b.setConsensusSubmitMessage(opBody);
}
Aggregations