/**
 * # Block Info
 * Information about the most recent block; including block hashes, current and
 * previous start times, etc...
 *
 * ### 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_timestamp.proto";

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

/**
 * Information for a transaction block.
 *
 * This includes:
 * - last block number.
 * - consensus times for:
 *    - previous block start.
 *    - current block start.
 *    - last handled transaction.
 * - hash data for a rolling window of 256 blocks.
 * - whether migration records were produced.
 */
message BlockInfo {

    /**
     * A block number.
     * <p>
     * The block number of the last completed immutable block.
     */
    int64 last_block_number = 1;

    /**
     * A consensus timestamp.
     * <p>
     * The consensus time of the first transaction for the last completed immutable block.
     */
    Timestamp first_cons_time_of_last_block = 2;

    /**
     * A list of the last 256 block hashes.<br/>
     * This is the SHA384 48 byte hashes of the previous 256 blocks,
     * collected in a single byte array.
     * <p>
     * The first 48 bytes SHALL be the oldest block in the list.<br/>
     * The last 48 bytes SHALL be the newest block, which is the last fully
     * completed immutable block.<br/>
     * This SHALL contain less than 256 block hashes if there are less than 256
     * preceding blocks; for instance, shortly after network genesis the network
     * will not have processed 256 blocks yet.
     * <p>
     * This MAY change significantly for Block Stream (HIP TBD).
     */
    bytes block_hashes = 3;

    /**
     * A consensus timestamp.
     * <p>
     * The consensus time of the last transaction that was handled by the node
     * within the current block. Only top-level transactions can trigger stake
     * period side effects, so we track them separately from the last-used
     * time of <i>all</i> transactions, which include children.<br/>
     */
    Timestamp cons_time_of_last_handled_txn = 4;

    /**
     * A flag indicating that migration records have been published.
     * <p>
     * This property SHALL be `false` immediately following a node upgrade<br/>
     * This SHALL be set 'true' as migration records, if any, are published.
     * Migration records are typically published "during" the first transaction
     * handled by the node following startup.
     */
    bool migration_records_streamed = 5;

    /**
     * A consensus timestamp.
     * <p>
     * The consensus time of the first transaction in the current block;
     * necessary for reconnecting nodes to detect when the current block
     * is finished.
     */
    Timestamp first_cons_time_of_current_block = 6;

    /**
     * The consensus time of the last transaction that was handled by the node.
     * <p>
     * This property is how we 'advance the consensus clock'. The node MUST
     * continually set this property to the consensus timestamp for the most
     * recent transaction completed by the node.
     */
    Timestamp last_used_cons_time = 7;

    /**
     * The time stamp at which the last interval process was done.
     * <p>
     * This field SHALL hold the consensus time for the last time
     * at which an interval of time-dependent events were processed.
     */
    proto.Timestamp last_interval_process_time = 8;
}
