// Copyright 2020 The Exonum Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// The messages collection for the default Exonum consensus implementation.

syntax = "proto3";

package exonum;

option java_package = "com.exonum.messages.core";

import "exonum/crypto/types.proto";
import "exonum/runtime/base.proto";
import "google/protobuf/timestamp.proto";

// Container for the signed messages.
message SignedMessage {
  // Payload of the message as a serialized `ExonumMessage`.
  bytes payload = 1;
  // Public key of the author of the message.
  exonum.crypto.PublicKey author = 2;
  // Digital signature over the payload created with a secret key of the author of the message.
  exonum.crypto.Signature signature = 3;
}

// Subset of Exonum messages defined in the Exonum core.
message CoreMessage {
  oneof kind {
    // Transaction message.
    exonum.runtime.AnyTx any_tx = 1;
    // Precommit (block endorsement) message.
    Precommit precommit = 2;
  }
}

// Pre-commit for a block, essentially meaning that a validator node endorses the block.
message Precommit {
  // ID of the validator endorsing the block.
  uint32 validator = 1;
  // The height to which the message is related.
  uint64 height = 2;
  // The round to which the message is related.
  uint32 round = 3;
  // Hash of the block proposal. Note that the proposal format is not defined by the core.
  exonum.crypto.Hash propose_hash = 4;
  // Hash of the new block.
  exonum.crypto.Hash block_hash = 5;
  // Local time of the validator node when the `Precommit` was created.
  google.protobuf.Timestamp time = 6;
}
