Skip to main content

stratum_apps/utils/
types.rs

1use stratum_core::{codec_sv2::StandardSv2Frame, parsers_sv2::AnyMessage};
2
3pub const GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS: u64 = 5;
4
5pub type TemplateId = u64;
6pub type UpstreamJobId = u32;
7pub type JobId = u32;
8pub type DownstreamId = usize;
9pub type RequestId = u32;
10pub type ChannelId = u32;
11pub type Hashrate = f32;
12pub type SharesPerMinute = f32;
13pub type SharesBatchSize = usize;
14pub type ExtensionType = u16;
15pub type MessageType = u8;
16pub type JdToken = u64;
17
18pub type Message = AnyMessage<'static>;
19pub type Sv2Frame = StandardSv2Frame<Message>;
20
21#[derive(Debug, PartialEq, Eq, Hash)]
22pub struct VardiffKey {
23    pub downstream_id: DownstreamId,
24    pub channel_id: ChannelId,
25}
26
27impl From<(DownstreamId, ChannelId)> for VardiffKey {
28    fn from(value: (DownstreamId, ChannelId)) -> Self {
29        VardiffKey {
30            downstream_id: value.0,
31            channel_id: value.1,
32        }
33    }
34}
35
36/// Marker traits used to define set of action
37/// the implementor can take
38pub trait CanDisconnect {}
39pub trait CanFallback {}
40pub trait CanShutdown {}