use serde::Serialize;
#[derive(Serialize)]
pub struct Request<P: Serialize> {
pub id: u64,
pub method: &'static str,
pub params: P,
}
#[derive(Serialize)]
pub struct LoginParams {
login: String,
pass: String,
agent: &'static str,
}
impl LoginParams {
pub fn new(login: &str, pass: &str) -> Self {
Self {
login: login.into(),
pass: pass.into(),
agent: "opt-in-miner/0.1",
}
}
}
#[derive(Serialize)]
pub struct SubmitParams {
id: String,
job_id: String,
nonce: String,
result: String,
}
impl SubmitParams {
pub fn new(id: &str, job_id: &str, nonce: &str, result: &str) -> Self {
Self {
id: id.into(),
job_id: job_id.into(),
nonce: nonce.into(),
result: result.into(),
}
}
}
#[derive(Serialize)]
pub struct KeepalivedParams {
id: String,
}
impl KeepalivedParams {
pub fn new(id: &str) -> Self {
Self { id: id.into() }
}
}