syntax = "proto3";

package com.hedera.hapi.node.state.roster;

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

/**
 * The current state of platform rosters.<br/>
 * This message stores a roster data for the platform in network state.
 *
 * The roster state SHALL encapsulate the incoming candidate roster's hash,
 * and a list of pairs of round number and active roster hash.<br/>
 * This data SHALL be used to track round numbers and the rosters used in determining the consensus.<br/>
 */
message RosterState {
    /**
     * The SHA-384 hash of a candidate roster.
     * <p>
     * This is the hash of the roster that is currently being considered
     * for adoption.<br/>
     * A Node SHALL NOT, ever, have more than one candidate roster
     * at the same time.
     */
    bytes candidate_roster_hash = 1;

    /**
     * A list of round numbers and roster hashes.<br/>
     * The round number indicates the round in which the corresponding roster became active
     * <p>
     * This list SHALL be ordered by round numbers in descending order.
     */
    repeated RoundRosterPair round_roster_pairs = 2;

    /**
      * Indicates whether the roster transplant is in progress.<br/>
      * This is needed to determine if all the node creations and deletions are complete.
      * True while a transplant roster is still being processed (nodes are
      * being created/updated/deleted).  Reset to false once dispatch is finished.
      *
      * <p>
      * A transplant roster is one that has been adopted from another network
      * using an override startup asset, rather than being generated by the current network's consensus.
     */
    bool transplant_in_progress = 3;
}

/**
 * A pair of round number and active roster hash.
 * <p>
 * This message SHALL encapsulate the round number and the hash of the
 * active roster used for that round.
 */
message RoundRosterPair {
    /**
     * The round number.
     * <p>
     * This value SHALL be the round number of the consensus round in which this roster became active.
     */
    uint64 round_number = 1;

    /**
     * The SHA-384 hash of the active roster for the given round number.
     * <p>
     * This value SHALL be the hash of the active roster used for the round.
     */
    bytes active_roster_hash = 2;
}
