syntax = "proto3";

import "blockchain.proto";
package types;
option go_package = "github.com/33cn/chain33/types";

message Operation {
    Block value = 1;
}

message Checkpoint {
    uint32 sequence = 1;
    bytes  digest   = 2;
}

message Entry {
    uint32 sequence = 1;
    bytes  digest   = 2;
    uint32 view     = 3;
}

message ViewChange {
    uint32 viewchanger = 1;
    bytes  digest      = 2;
}

message Summary {
    uint32 sequence = 1;
    bytes  digest   = 2;
}

message Result {
    Block value = 1;
}

// -------------------------------- //

message Request {
    oneof value {
        RequestClient     client     = 1;
        RequestPrePrepare preprepare = 2;
        RequestPrepare    prepare    = 3;
        RequestCommit     commit     = 4;
        RequestCheckpoint checkpoint = 5;
        RequestViewChange viewchange = 6;
        RequestAck        ack        = 7;
        RequestNewView    newview    = 8;
    }
}

message RequestClient {
    Operation op        = 1;
    string    timestamp = 2;
    string    client    = 3;
}

message RequestPrePrepare {
    uint32 view     = 1;
    uint32 sequence = 2;
    bytes  digest   = 3;
    uint32 replica  = 4;
}

message RequestPrepare {
    uint32 view     = 1;
    uint32 sequence = 2;
    bytes  digest   = 3;
    uint32 replica  = 4;
}

message RequestCommit {
    uint32 view     = 1;
    uint32 sequence = 2;
    uint32 replica  = 3;
}

message RequestCheckpoint {
    uint32 sequence = 1;
    bytes  digest   = 2;
    uint32 replica  = 3;
}

message RequestViewChange {
    uint32   view                   = 1;
    uint32   sequence               = 2;
    repeated Checkpoint checkpoints = 3;
    repeated Entry preps            = 4;
    repeated Entry prepreps         = 5;
    uint32         replica          = 6;
}

message RequestAck {
    uint32 view        = 1;
    uint32 replica     = 2;
    uint32 viewchanger = 3;
    bytes  digest      = 4;
}

message RequestNewView {
    uint32   view                   = 1;
    repeated ViewChange viewchanges = 2;
    repeated Summary summaries      = 4;
    uint32           replica        = 5;
}

message ClientReply {
    uint32 view      = 1;
    string timestamp = 2;
    string client    = 3;
    uint32 replica   = 4;
    Result result    = 5;
}