1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_tuple::*;

//General Packets are those that don't change depending on the stratum implementation.
//Stratum Packets are those that do change depending on the implementation.
//Thoughts -> We could also have pool packets here since we won't have the same difficulties that
//we did in autonomy with it - since there is only 1 protocol. Then Authorize could be in pool
//packets, but if we are only seeing a single packet that can fit there, I don't know if I would
//see that as worth it.
pub mod general_packets;
pub mod stratum_packets;
//@todo need some renaming on this bad boy.
use crate::traits::{PoolParams, StratumParams};
pub use general_packets::{
    GetTransactionsParam, GetVersionParam, ReconnectParam, ShowMessageParam,
};
pub use stratum_packets::{
    AuthorizeParam, CapabilitiesParam, NotifyParam, SetDifficultyParam, SetExtraNonceParam,
    SetGoalParam, SubmitParam, SubscribeParam, SuggestDifficultyParam, SuggestTargetParam,
};

//@todo I think I need to break this into Pool params and client params.
//The play also may be to rename this to PoolParam and ClientParam (non-plural).
//
//Messages from the pool to the client
// #[derive(Debug, Clone, Serialize_tuple, Deserialize_tuple)]
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum PoolParam<PP, SP>
where
    PP: PoolParams,
    SP: StratumParams,
{
    Notify(SP::Notify),
    SetDifficulty(f64),

    // ===== Responding Values ===== //
    AuthorizeResult(PP::Authorized),
    SubscribeResult(PP::SubscribeResult),
    SubmitResult(bool),

    Unknown(Value),
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum ClientParam<PP, SP>
where
    PP: PoolParams,
    SP: StratumParams,
{
    Authorize(PP::Authorize),
    Submit(SP::Submit),
    Subscribe(PP::Subscribe),
    Unknown(Value),
}