Struct stratum_server::Connection
source · [−]pub struct Connection<State> {Show 16 fields
pub id: Uuid,
pub session_id: u32,
pub info: Arc<RwLock<ConnectionInfo>>,
pub user_info: Arc<Mutex<UserInfo>>,
pub sender: Arc<Mutex<UnboundedSender<SendInformation>>>,
pub upstream_sender: Arc<Mutex<UnboundedSender<String>>>,
pub upstream_receiver: Arc<Mutex<UnboundedReceiver<Map<String, Value>>>>,
pub difficulty: Arc<Mutex<f64>>,
pub next_difficulty: Arc<Mutex<Option<f64>>>,
pub options: Arc<MinerOptions>,
pub needs_ban: Arc<Mutex<bool>>,
pub state: Arc<Mutex<State>>,
pub stop_source: Arc<Mutex<Option<StopSource>>>,
pub stop_token: StopToken,
pub connection_miner: Arc<Mutex<Option<Miner>>>,
pub miner_list: MinerList,
}
Fields
id: Uuid
session_id: u32
info: Arc<RwLock<ConnectionInfo>>
user_info: Arc<Mutex<UserInfo>>
sender: Arc<Mutex<UnboundedSender<SendInformation>>>
upstream_sender: Arc<Mutex<UnboundedSender<String>>>
upstream_receiver: Arc<Mutex<UnboundedReceiver<Map<String, Value>>>>
difficulty: Arc<Mutex<f64>>
next_difficulty: Arc<Mutex<Option<f64>>>
options: Arc<MinerOptions>
needs_ban: Arc<Mutex<bool>>
state: Arc<Mutex<State>>
stop_source: Arc<Mutex<Option<StopSource>>>
stop_token: StopToken
connection_miner: Arc<Mutex<Option<Miner>>>
miner_list: MinerList
Implementations
sourceimpl<State: Clone + Send + Sync + 'static> Connection<State>
impl<State: Clone + Send + Sync + 'static> Connection<State>
pub fn new(
session_id: u32,
sender: UnboundedSender<SendInformation>,
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 send_raw(&self, message: Buffer) -> 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)
pub async fn disconnect(&self)
pub async fn ban(&self)
pub async fn needs_ban(&self) -> bool
pub fn id(&self) -> Uuid
pub async fn add_main_worker(&self, worker_id: Uuid)
pub async fn get_main_worker(&self) -> Option<Miner>
pub async fn register_worker(
&self,
session_id: u32,
client_agent: &str,
worker_name: &str,
worker_id: Uuid
)
pub async fn unregister_worker(&self, session_id: u32) -> Option<Miner>
pub async fn get_worker_list(&self) -> MinerList
pub async fn get_worker_by_session_id(&self, session_id: u32) -> Option<Miner>
pub async fn update_worker_by_session_id(&self, session_id: u32, miner: Miner)
pub async fn set_user_info(
&self,
account_id: i32,
mining_account_id: i32,
worker_name: Option<String>
)
pub async fn get_user_info(&self) -> UserInfo
pub async fn set_client(&self, client: &str)
pub async fn get_connection_info(&self) -> ConnectionInfo
pub async fn is_long_timeout(&self) -> bool
pub fn get_session_id(&self) -> u32
pub async fn subscribed(&self) -> bool
pub async fn subscribe(&self)
pub async fn is_agent(&self) -> bool
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
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