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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use serde::{Deserialize, Serialize};
use serde_json::Value;

//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;
use crate::traits::StratumPackets;
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.
//
//Messages from the pool to the client
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum PoolParams<SP>
where
    SP: StratumPackets,
{
    // ===== Sending Values ===== //
    GetVersion(GetVersionParam),
    Reconnect(ReconnectParam),
    ShowMessage(ShowMessageParam),
    //Trait
    Notify(NotifyParam<SP::Notify>),
    //The only reason why I'm thinking of keeping this a trait right now is that for Handshake in
    //the set Difficulty call we could also set the mask.
    SetDifficulty(SetDifficultyParam<SP::SetDifficulty>),
    SetExtraNonce(SetExtraNonceParam<SP::SetExtraNonce>),
    //Trait forsure
    SetGoal(SetGoalParam<SP::SetGoal>),

    // ===== Responding Values ===== //
    // @todo see if this would be an easier method of using this trait.
    // AuthorizeResult(SP::Authorize),
    // @todo force bool for login? I feel like this is the correct response.
    AuthorizeResult(bool),
    // GetTransactionsResult(GetTransactions<SP::GetTransactionsResult>), @todo
    SubmitResult(bool),
    // SubscribeResult(SubscribeResult<SP::SubscribeResult>), @todo

    //Just keeps the json value inside of this for future impl compabability.
    Unknown(Value),
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum ClientParams<SP>
where
    SP: StratumPackets,
{
    //Trait
    Authorize(AuthorizeParam<SP::Authorize>),
    //Trait ?
    Capabilities(CapabilitiesParam<SP::Capabilities>),
    ExtraNonceSubscribe,
    GetTransactions(GetTransactionsParam),
    //Trait
    Submit(SubmitParam<SP::Submit>),
    //Trait
    Subscribe(SubscribeParam<SP::Subscribe>),
    //Maybe Trait
    SuggestDifficulty(SuggestDifficultyParam<SP::SuggestDifficulty>),
    //Maybe Trait
    SuggestTarget(SuggestTargetParam<SP::SuggestTarget>),
    //Just keeps the json value inside of this for future impl compabability.
    Unknown(Value),
}