syntax = "proto3";

package basalt;

option go_package = "github.com/psila-ai/basalt-protocol/go/basalt";

message AppendRequest {
  bytes payload = 1;
  // 0=Log, 1=Checkpoint, 2=Config, 3=System
  uint32 entry_type = 2;
}

message AppendResponse {
    uint64 offset = 1;
    bytes hash = 2;
}

message ReadRequest {
    uint64 offset = 1;
    uint64 length = 2;
}

message ReadResponse {
    bytes payload = 1;
}

message ConsensusMessage {
    bytes message = 1;
}

message ConsensusResponse {}

message HandshakeRequest {
    uint64 node_id = 1;
}

message HandshakeResponse {
    uint64 node_id = 1;
}

message QueryRequest {
    string query = 1;
}

message QueryResponse {
    bytes result = 1;
}

service BasaltService {
    rpc Append (AppendRequest) returns (AppendResponse);
    rpc Read (ReadRequest) returns (ReadResponse);
    rpc Consensus (ConsensusMessage) returns (ConsensusResponse);
    rpc Handshake (HandshakeRequest) returns (HandshakeResponse);
    rpc ExecuteQuery (QueryRequest) returns (QueryResponse);
}
