/**
 * # Submit Message
 * Submit a message to a topic via the Hedera Consensus Service (HCS).
 *
 * ### Keywords
 * The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
 * "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
 * document are to be interpreted as described in
 * [RFC2119](https://www.ietf.org/rfc/rfc2119) and clarified in
 * [RFC8174](https://www.ietf.org/rfc/rfc8174).
 */
syntax = "proto3";

package proto;

// SPDX-License-Identifier: Apache-2.0
option java_package = "com.hederahashgraph.api.proto.java";
// <<<pbj.java_package = "com.hedera.hapi.node.consensus">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

import "services_basic_types.proto";

/**
 * Consensus message "chunk" detail.<br/>
 * This message carries information describing the way in which a message
 * submitted for consensus is broken into multiple fragments to fit within
 * network transaction size limits.
 *
 * The use of multiple message fragments is RECOMMENDED for any message
 * greater than 4KiB in total size.
 *
 * ### Block Stream Effects
 * None
 */
message ConsensusMessageChunkInfo {
    /**
     * The TransactionID of the first chunk.
     * <p>
     * This MUST be set for every chunk in a fragmented message.
     */
    TransactionID initialTransactionID = 1;

    /**
     * The total number of chunks in the message.
     */
    int32 total = 2;

    /**
     * The sequence number (from 1 to total) of the current chunk
     * in the message.
     */
    int32 number = 3;
}

/**
 * Submit a message for consensus.<br/>
 * This transaction adds a new entry to the "end" of a topic, and provides
 * the core function of the consensus service.
 *
 * Valid and authorized messages on valid topics SHALL be ordered by the
 * consensus service, published in the block stream, and available to all
 * subscribers on this topic via the mirror nodes.<br/>
 * If this transaction succeeds the resulting `TransactionReceipt` SHALL contain
 * the latest `topicSequenceNumber` and `topicRunningHash` for the topic.<br/>
 * If the topic `submitKey` is set, and not an empty `KeyList`, then that key
 * MUST sign this transaction.
 *
 * ### Block Stream Effects
 * None
 */
message ConsensusSubmitMessageTransactionBody {
    /**
     * Topic to submit message to.
     */
    TopicID topicID = 1;

    /**
     * A message to be submitted.
     * <p>
     * This Transaction (including signatures) MUST be less than 6KiB.<br/>
     * Messages SHOULD be less than 4KiB. A "chunked" message MAY be submitted
     * if a message larger than this is required.
     */
    bytes message = 2;

    /**
     * Information for the current "chunk" in a fragmented message.
     * <p>
     * This value is REQUIRED if the full `message` is submitted in two or
     * more fragments due to transaction size limits.<br/>
     * If the message is submitted in a single transaction, then this
     * field SHOULD NOT be set.
     */
    ConsensusMessageChunkInfo chunkInfo = 3;
}
