// Copyright 2016 Intel Corporation
//
// 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.
// -----------------------------------------------------------------------------

syntax = "proto3";
option java_multiple_files = true;
option java_package = "sawtooth.sdk.protobuf";
option go_package = "block_pb2";

import "batch.proto";

message BlockHeader {
    // Block number in the chain
    uint64 block_num = 1;

    // The header_signature of the previous block that was added to the chain.
    string previous_block_id = 2;

    // Public key for the component internal to the validator that
    // signed the BlockHeader
    string signer_public_key = 3;

    // List of batch.header_signatures that match the order of batches
    // required for the block
    repeated string batch_ids = 4;

    // Bytes that are set and verified by the consensus algorithm used to
    // create and validate the block
    bytes consensus = 5;

    // The state_root_hash should match the final state_root after all
    // transactions in the batches have been applied, otherwise the block
    // is not valid
    string state_root_hash = 6;
}

message Block {
    // The serialized version of the BlockHeader
    bytes header = 1;

    // The signature derived from signing the header
    string header_signature = 2;

    // A list of batches. The batches may contain new batches that other
    // validators may not have received yet, or they will be all batches needed
    // for block validation when passed to the journal
    repeated Batch batches = 3;
}
