Struct stratum_server::Connection
source · [−]pub struct Connection<State> {Show 23 fields
pub session_id: u32,
pub sender: Arc<Mutex<UnboundedSender<String>>>,
pub upstream_sender: Arc<Mutex<UnboundedSender<String>>>,
pub upstream_receiver: Arc<Mutex<UnboundedReceiver<Map<String, Value>>>>,
pub authorized: Arc<Mutex<bool>>,
pub subscribed: Arc<Mutex<bool>>,
pub agent: Arc<Mutex<bool>>,
pub session_start: SystemTime,
pub connection_state: Mutex<ConnectionState>,
pub difficulty: Arc<Mutex<f64>>,
pub stats: Arc<Mutex<MinerStats>>,
pub needs_ban: Arc<Mutex<bool>>,
pub next_difficulty: Arc<Mutex<Option<f64>>>,
pub id: Uuid,
pub job_stats: Arc<Mutex<JobStats>>,
pub options: Arc<MinerOptions>,
pub var_diff: Arc<Mutex<bool>>,
pub last_message_id: Arc<Mutex<ID>>,
pub worker_info: Arc<Mutex<WorkerInfo>>,
pub state: Arc<Mutex<State>>,
pub stop_source: Arc<Mutex<Option<StopSource>>>,
pub stop_token: StopToken,
pub worker_list: Arc<Mutex<HashMap<u16, AgentWorkerInfo>>>,
}
Fields
session_id: u32
sender: Arc<Mutex<UnboundedSender<String>>>
upstream_sender: Arc<Mutex<UnboundedSender<String>>>
upstream_receiver: Arc<Mutex<UnboundedReceiver<Map<String, Value>>>>
subscribed: Arc<Mutex<bool>>
agent: Arc<Mutex<bool>>
session_start: SystemTime
connection_state: Mutex<ConnectionState>
difficulty: Arc<Mutex<f64>>
stats: Arc<Mutex<MinerStats>>
needs_ban: Arc<Mutex<bool>>
next_difficulty: Arc<Mutex<Option<f64>>>
id: Uuid
job_stats: Arc<Mutex<JobStats>>
options: Arc<MinerOptions>
var_diff: Arc<Mutex<bool>>
last_message_id: Arc<Mutex<ID>>
worker_info: Arc<Mutex<WorkerInfo>>
state: Arc<Mutex<State>>
stop_source: Arc<Mutex<Option<StopSource>>>
stop_token: StopToken
worker_list: Arc<Mutex<HashMap<u16, AgentWorkerInfo>>>
Implementations
sourceimpl<State: Clone + Send + Sync + 'static> Connection<State>
impl<State: Clone + Send + Sync + 'static> Connection<State>
pub fn new(
session_id: u32,
addr: SocketAddr,
sender: UnboundedSender<String>,
upstream_sender: UnboundedSender<String>,
upstream_receiver: UnboundedReceiver<Map<String, Value>>,
initial_difficulty: f64,
var_diff_config: VarDiffConfig,
state: State
) -> Self
pub async fn is_disconnected(&self) -> bool
pub async fn send<T: Serialize>(&self, message: T) -> Result<()>
pub async fn upstream_send<T: Serialize>(&self, message: T) -> Result<()>
pub async fn upstream_result(&self) -> Result<(Value, Value)>
pub async fn shutdown(&self) -> Result<()>
pub async fn disconnect(&self)
pub async fn ban(&self)
pub async fn needs_ban(&self) -> bool
pub async fn get_stats(&self) -> MinerStats
pub fn id(&self) -> Uuid
pub async fn set_sid(&self, sid: Option<String>, sid_size: usize) -> String
pub async fn register_worker(
&self,
session_id: u16,
client_agent: &str,
worker_name: &str,
worker_id: Uuid
)
pub async fn unregister_worker(&self, session_id: u16)
pub async fn get_worker_list(&self) -> HashMap<u16, AgentWorkerInfo>
pub async fn get_worker_by_session_id(
&self,
session_id: u16
) -> Option<AgentWorkerInfo>
pub async fn update_worker_by_session_id(
&self,
session_id: u16,
worker: AgentWorkerInfo
)
pub async fn set_var_diff(&self, var_diff: bool)
pub async fn set_worker_name(&self, name: Option<String>)
pub async fn set_account_id(&self, id: i32)
pub async fn get_account_id(&self) -> i32
pub async fn set_miner_account(&self, id: Option<i32>)
pub async fn get_miner_account(&self) -> Option<i32>
pub async fn set_client(&self, client: &str)
pub async fn get_client(&self) -> Option<String>
pub async fn set_worker_id(&self, id: Uuid)
pub async fn get_sid(&self) -> Option<Buffer>
pub fn get_session_id(&self) -> u32
pub async fn get_worker(&self) -> WorkerInfo
pub async fn subscribed(&self) -> bool
pub async fn subscribe(&self)
pub async fn set_difficulty(&self, difficulty: f64)
pub async fn get_difficulty(&self) -> f64
pub async fn get_state(&self) -> State
pub async fn set_state(&self, state: State)
pub async fn update_difficulty(&self) -> Option<f64>
pub fn get_stop_token(&self) -> StopToken
pub async fn consider_ban(&self)
Trait Implementations
Auto Trait Implementations
impl<State> !RefUnwindSafe for Connection<State>
impl<State> Send for Connection<State> where
State: Send,
impl<State> Sync for Connection<State> where
State: Send,
impl<State> Unpin for Connection<State>
impl<State> !UnwindSafe for Connection<State>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more