2021-05-10 00:49:01 +02:00
|
|
|
use crate::{Chain, Keystore, Settings};
|
2021-02-21 21:56:56 +01:00
|
|
|
#[allow(unused_imports)]
|
2021-02-20 16:28:10 +01:00
|
|
|
use log::{trace, debug, info, warn, error};
|
2021-04-20 20:54:45 +02:00
|
|
|
use crate::miner::MinerState;
|
2020-04-18 21:31:40 +02:00
|
|
|
|
|
|
|
|
pub struct Context {
|
2021-03-21 00:48:32 +01:00
|
|
|
pub app_version: String,
|
2021-02-13 23:37:44 +01:00
|
|
|
pub settings: Settings,
|
2021-03-23 18:55:11 +01:00
|
|
|
pub keystore: Option<Keystore>,
|
2021-03-10 22:21:50 +01:00
|
|
|
pub chain: Chain,
|
2021-04-20 20:54:45 +02:00
|
|
|
pub miner_state: MinerState,
|
2020-04-18 21:31:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Context {
|
|
|
|
|
/// Creating an essential context to work with
|
2021-03-23 18:55:11 +01:00
|
|
|
pub fn new(app_version: String, settings: Settings, keystore: Option<Keystore>, chain: Chain) -> Context {
|
2021-04-20 20:54:45 +02:00
|
|
|
Context {
|
|
|
|
|
app_version,
|
|
|
|
|
settings,
|
|
|
|
|
keystore,
|
|
|
|
|
chain,
|
|
|
|
|
miner_state: MinerState { mining: false, full: false }
|
|
|
|
|
}
|
2020-04-18 21:31:40 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 18:55:11 +01:00
|
|
|
pub fn get_keystore(&self) -> Option<Keystore> {
|
2020-04-18 21:31:40 +02:00
|
|
|
self.keystore.clone()
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 18:55:11 +01:00
|
|
|
pub fn set_keystore(&mut self, keystore: Option<Keystore>) {
|
2020-04-18 21:31:40 +02:00
|
|
|
self.keystore = keystore;
|
|
|
|
|
}
|
2021-01-14 18:34:43 +01:00
|
|
|
|
2021-03-10 22:21:50 +01:00
|
|
|
pub fn get_chain(&self) -> &Chain {
|
|
|
|
|
&self.chain
|
2021-01-14 18:34:43 +01:00
|
|
|
}
|
2020-04-18 21:31:40 +02:00
|
|
|
}
|