/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric/protos/orderer/etcdraft";
option java_package = "org.hyperledger.fabric.protos.orderer.etcdraft";

package etcdraft;

// ConfigMetadata is serialized and set as the value of ConsensusType.Metadata in
// a channel configuration when the ConsensusType.Type is set "etcdraft".
message ConfigMetadata {
    repeated Consenter consenters = 1;
    Options options = 2;
}

// Consenter represents a consenting node (i.e. replica).
message Consenter {
    string host = 1;
    uint32 port = 2;
    bytes client_tls_cert = 3;
    bytes server_tls_cert = 4;
}

// Options to be specified for all the etcd/raft nodes. These can be modified on a
// per-channel basis.
message Options {
	string tick_interval = 1; // time duration format, e.g. 500ms
	uint32 election_tick = 2;
	uint32 heartbeat_tick = 3;
	uint32 max_inflight_blocks = 4;
	// Take snapshot when cumulative data exceeds certain size in bytes.
	uint32 snapshot_interval_size = 5;
}

// BlockMetadata stores data used by the Raft OSNs when
// coordinating with each other, to be serialized into
// block meta dta field and used after failres and restarts.
message BlockMetadata {
    // Maintains a mapping between the cluster's OSNs
    // and their Raft IDs.
    repeated uint64 consenter_ids = 1;
    // Carries the Raft ID value that will be assigned
    // to the next OSN that will join this cluster.
    uint64 next_consenter_id = 2;
    // Index of etcd/raft entry for current block.
    uint64 raft_index = 3;
}
