// Distributed under the MIT software license, see the accompanying
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.

syntax = "proto3";

package qrl;

import "qrl.proto";

// Adding old code to refactor while keeping things working
message LegacyMessage {
    enum FuncName {
        VE = 0;             // Version
        PL = 1;             // Peers List
        PONG = 2;           // Pong TODO: Obsolete

        MR = 3;             // Message received
        SFM = 4;            // Send Full Message
        BK = 5;             // Block
        FB = 6;             // Fetch request for block
        PB = 7;             // Push Block
        BH = 8;             // Block Height

        ST = 9;             // Stake Transaction
        DST = 10;           // Destake Transaction
        DT = 11;            // Duplicate Transaction
        TX = 12;            // Transfer Transaction
        VT = 13;            // Vote
        LT = 14;            // Lattice Transaction
        EPH = 15;           // Ephemeral
        MT = 16;            // Message Transaction
        TK = 17;            // Token Transaction
        TT = 18;            // Transfer Token Transaction
        SL = 19;            // Slave Transaction
        SYNC = 20;          // Add into synced list, if the node replies
        CHAINSTATE = 21;    // Chain State
        HEADERHASHES = 22;  //
        P2P_ACK = 23;       // P2P Acknowledgement
    }

    FuncName func_name = 1;

    oneof data {
        NoData noData = 2;
        VEData veData = 3;
        PLData plData = 4;
        PONGData pongData = 5;
        MRData mrData = 6;
        Block block = 7;
        FBData fbData = 8;
        PBData pbData = 9;
        BlockHeightData bhData = 10;
        Transaction stData = 11;
        Transaction dstData = 12;
        Transaction dtData = 13;
        Transaction txData = 14;
        Transaction vtData = 15;
        Transaction mtData = 16;
        Transaction tkData = 17;
        Transaction ttData = 18;
        Transaction ltData = 19;
        Transaction slData = 20;
        EncryptedEphemeralMessage ephData = 21;
        SYNCData syncData = 22;
        NodeChainState chainStateData = 23;
        NodeHeaderHash nodeHeaderHash = 24;
        P2PAcknowledgement p2pAckData = 25;
    }
}

message NoData { }

message VEData
{
    string version = 1;
    bytes genesis_prev_hash = 2;
}

message PLData
{
    repeated string peer_ips = 1;
}

message PONGData
{
}

message MRData {
    bytes hash = 1;                                     // FIXME: rename this to block_headerhash
    LegacyMessage.FuncName type = 2;                    // FIXME: type/string what is this
    bytes stake_selector = 3;
    uint64 block_number = 4;
    bytes prev_headerhash = 5;
    bytes reveal_hash = 6;
}

message BKData {
    MRData mrData = 1;
    Block block = 2;
}

message FBData {
    uint64 index = 1;
}

message PBData {
    Block block = 1;
}

message SYNCData
{
    string state = 1;
}
