/**
 * # Record Cache
 * The Record Cache holds transaction records for a short time, and is the
 * source for responses to `transactionGetRecord` and `transactionGetReceipt`
 * queries.
 *
 * ### 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
import "services_basic_types.proto";
import "services_transaction_record.proto";
import "services_response_code.proto";

option java_package = "com.hederahashgraph.api.proto.java";
// <<<pbj.java_package = "com.hedera.hapi.node.state.recordcache">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

/**
 * As transactions are handled and records and receipts are created, they are
 * stored in state for a configured time period (for example, 3 minutes).
 * During this time, any client can query the node and get the record or receipt
 * for the transaction. The `TransactionRecordEntry` is the object stored in
 * state with this information.
 */
message TransactionRecordEntry {
    /**
     * A node identifier.<br/>
     * This identifier is the node, as known to the address book, that
     * submitted the transaction for consensus.
     * <p>
     * This SHALL be a whole number.
     */
    int64 node_id = 1;

    /**
     * An Account identifier for the payer for the transaction.
     * <p>
     * This MAY be the same as the account ID within the Transaction ID of the
     * record, or it MAY be the account ID of the node that submitted the
     * transaction to consensus if the account ID in the Transaction ID was
     * not able to pay.
     */
    AccountID payer_account_id = 2;

    /**
     * A transaction record for the transaction.
     */
    TransactionRecord transaction_record = 3;
}

/**
 * An entry in the record cache with the receipt for a transaction.
 * This is the entry stored in state that enables returning the receipt
 * information when queried by clients.
 *
 * When a transaction is handled a receipt SHALL be created.<br/>
 * This receipt MUST be stored in state for a configured time limit
 * (e.g. 3 minutes).<br/>
 * While a receipt is stored, a client MAY query the node and retrieve
 * the receipt.
 */
message TransactionReceiptEntry {
    /**
     * A node identifier.<br/>
     * This identifies the node that submitted the transaction to consensus.
     * The value is the identifier as known to the current address book.
     * <p>
     * Valid node identifiers SHALL be between 0 and <tt>2<sup>63-1</sup></tt>,
     * inclusive.
     */
    uint64 node_id = 1;

    /**
     * A transaction identifier.<br/>
     * This identifies the submitted transaction for this receipt.
     */
    TransactionID transaction_id = 2;

    /**
     * A status result.<br/>
     * This is the final status after handling the transaction.
     */
    ResponseCodeEnum status = 3;
}

/**
 * A cache of transaction receipts.<br/>
 * As transactions are handled and receipts are created, they are stored in
 * state for a configured time limit (perhaps, for example, 3 minutes).
 * During this time window, any client can query the node and get the receipt
 * for the transaction. The `TransactionReceiptEntries` is the object stored in
 * state with this information.
 *
 * This message SHALL contain a list of `TransactionReceiptEntry` objects.
 */
message TransactionReceiptEntries {
    repeated TransactionReceiptEntry entries = 1;
}
