quantus_miner_api/
lib.rs

1use serde::{Deserialize, Serialize};
2
3/// Status codes returned in API responses.
4#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
5#[serde(rename_all = "snake_case")]
6pub enum ApiResponseStatus {
7	Accepted,
8	Running,
9	Completed,
10	Failed,
11	Cancelled,
12	NotFound,
13	Error,
14}
15
16/// Request payload sent from Node to Miner (`/mine` endpoint).
17#[derive(Serialize, Deserialize, Debug, Clone)]
18pub struct MiningRequest {
19	pub job_id: String,
20	/// Hex encoded header hash (32 bytes -> 64 chars, no 0x prefix)
21	pub mining_hash: String,
22	/// Distance threshold (u64 as string)
23	pub distance_threshold: String,
24	/// Hex encoded start nonce (U512 -> 128 chars, no 0x prefix)
25	pub nonce_start: String,
26	/// Hex encoded end nonce (U512 -> 128 chars, no 0x prefix)
27	pub nonce_end: String,
28}
29
30/// Response payload for job submission (`/mine`) and cancellation (`/cancel`).
31#[derive(Serialize, Deserialize, Debug, Clone)]
32pub struct MiningResponse {
33	pub status: ApiResponseStatus,
34	pub job_id: String,
35	#[serde(skip_serializing_if = "Option::is_none")]
36	pub message: Option<String>,
37}
38
39/// Response payload for checking job results (`/result/{job_id}`).
40#[derive(Serialize, Deserialize, Debug, Clone)]
41pub struct MiningResult {
42	pub status: ApiResponseStatus,
43	pub job_id: String,
44	/// Hex encoded U512 representation of the final/winning nonce (no 0x prefix).
45	pub nonce: Option<String>,
46	/// Hex encoded [u8; 64] representation of the winning nonce (128 chars, no 0x prefix).
47	/// This is the primary field the Node uses for verification.
48	pub work: Option<String>,
49	pub hash_count: u64,
50	pub elapsed_time: f64,
51}