// 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";

service MiningAPI
{
    rpc GetBlockMiningCompatible(GetBlockMiningCompatibleReq) returns (GetBlockMiningCompatibleResp);
    rpc GetLastBlockHeader(GetLastBlockHeaderReq) returns (GetLastBlockHeaderResp);
    rpc GetBlockToMine(GetBlockToMineReq) returns (GetBlockToMineResp);
    rpc SubmitMinedBlock(SubmitMinedBlockReq) returns (SubmitMinedBlockResp);
}

message GetBlockMiningCompatibleReq {
    // Used for getlastblockheader and getblockheaderbyheight
    uint64 height = 1; // if height = 0, this means getlastblockheader
}


message GetLastBlockHeaderReq {
    uint64 height = 1;
}

message GetBlockMiningCompatibleResp {
    BlockHeader blockheader = 1;
    BlockMetaData blockmetadata = 2;
}

message GetLastBlockHeaderResp {
    uint64 difficulty = 1;
    uint64 height = 2;
    uint64 timestamp = 3;
    uint64 reward = 4;
    string hash = 5;
    uint64 depth = 6;
}

message GetBlockToMineReq {
    bytes wallet_address = 1;
}

message GetBlockToMineResp {
    string blocktemplate_blob = 1; // max length 112 bytes, otherwise xmr-stak will hiccup
    uint64 difficulty = 2; // difficulty that the new block should meet
    uint64 height = 3;
    uint32 reserved_offset = 4;
}

message SubmitMinedBlockReq {
    bytes blob = 1; // blocktemplate_blob with the correct nonce
}

message SubmitMinedBlockResp {
    bool error = 1; // It seems there are no special fields for success/error reporting, does gRPC automatically give me something?
}
