Search in sources :

Example 1 with ConsensusMessageChunkInfo

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());
}
Also used : ConsensusMessageChunkInfo(com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic)

Example 2 with ConsensusMessageChunkInfo

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);
}
Also used : ConsensusMessageChunkInfo(com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo) TopicMessage(com.hedera.mirror.common.domain.topic.TopicMessage) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 3 with ConsensusMessageChunkInfo

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);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TopicID(com.hederahashgraph.api.proto.java.TopicID) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) TxnUtils.asTransactionID(com.hedera.services.bdd.spec.transactions.TxnUtils.asTransactionID) OptionalInt(java.util.OptionalInt) Function(java.util.function.Function) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) TxnUtils.asTopicId(com.hedera.services.bdd.spec.transactions.TxnUtils.asTopicId) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ConsensusSubmitMessage(com.hederahashgraph.api.proto.java.HederaFunctionality.ConsensusSubmitMessage) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) SubmitMessageMeta(com.hedera.services.usage.consensus.SubmitMessageMeta) ConsensusMessageChunkInfo(com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) Optional(java.util.Optional) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) Collections(java.util.Collections) ConsensusMessageChunkInfo(com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo) TopicID(com.hederahashgraph.api.proto.java.TopicID) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody)

Aggregations

ConsensusMessageChunkInfo (com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo)3 ConsensusSubmitMessageTransactionBody (com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody)2 MoreObjects (com.google.common.base.MoreObjects)1 ByteString (com.google.protobuf.ByteString)1 TopicMessage (com.hedera.mirror.common.domain.topic.TopicMessage)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 AdapterUtils (com.hedera.services.bdd.spec.fees.AdapterUtils)1 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)1 TxnUtils.asTopicId (com.hedera.services.bdd.spec.transactions.TxnUtils.asTopicId)1 TxnUtils.asTransactionID (com.hedera.services.bdd.spec.transactions.TxnUtils.asTransactionID)1 TxnUtils.suFrom (com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom)1 MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)1 BaseTransactionMeta (com.hedera.services.usage.BaseTransactionMeta)1 SubmitMessageMeta (com.hedera.services.usage.consensus.SubmitMessageMeta)1 UsageAccumulator (com.hedera.services.usage.state.UsageAccumulator)1 FeeData (com.hederahashgraph.api.proto.java.FeeData)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 ConsensusSubmitMessage (com.hederahashgraph.api.proto.java.HederaFunctionality.ConsensusSubmitMessage)1 Key (com.hederahashgraph.api.proto.java.Key)1