Files
Alfis/src/context.rs
T

37 lines
942 B
Rust
Raw Normal View History

2021-05-10 00:49:01 +02:00
use crate::{Chain, Keystore, Settings};
#[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;
pub struct Context {
2021-03-21 00:48:32 +01:00
pub app_version: String,
pub settings: Settings,
pub keystore: Option<Keystore>,
pub chain: Chain,
2021-04-20 20:54:45 +02:00
pub miner_state: MinerState,
}
impl Context {
/// Creating an essential context to work with
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 }
}
}
pub fn get_keystore(&self) -> Option<Keystore> {
self.keystore.clone()
}
pub fn set_keystore(&mut self, keystore: Option<Keystore>) {
self.keystore = keystore;
}
2021-01-14 18:34:43 +01:00
pub fn get_chain(&self) -> &Chain {
&self.chain
2021-01-14 18:34:43 +01:00
}
}