io handlers
This commit is contained in:
parent
a4103e0830
commit
89dc6fa9cc
@ -445,6 +445,7 @@ impl Configuration {
|
|||||||
|
|
||||||
// Secret Store
|
// Secret Store
|
||||||
let account_service = Arc::new(AccountService::new());
|
let account_service = Arc::new(AccountService::new());
|
||||||
|
service.io().register_handler(account_service).expect("Error registering IO handler");
|
||||||
|
|
||||||
// Setup rpc
|
// Setup rpc
|
||||||
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
if self.args.flag_jsonrpc || self.args.flag_rpc {
|
||||||
@ -468,6 +469,7 @@ impl Configuration {
|
|||||||
client: service.client(),
|
client: service.client(),
|
||||||
info: Default::default(),
|
info: Default::default(),
|
||||||
sync: sync.clone(),
|
sync: sync.clone(),
|
||||||
|
accounts: account_service.clone(),
|
||||||
});
|
});
|
||||||
service.io().register_handler(io_handler).expect("Error registering IO handler");
|
service.io().register_handler(io_handler).expect("Error registering IO handler");
|
||||||
|
|
||||||
@ -559,20 +561,27 @@ impl Informant {
|
|||||||
|
|
||||||
const INFO_TIMER: TimerToken = 0;
|
const INFO_TIMER: TimerToken = 0;
|
||||||
|
|
||||||
|
const ACCOUNT_TICK_TIMER: TimerToken = 10;
|
||||||
|
const ACCOUNT_TICK_MS: u64 = 60000;
|
||||||
|
|
||||||
struct ClientIoHandler {
|
struct ClientIoHandler {
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
sync: Arc<EthSync>,
|
sync: Arc<EthSync>,
|
||||||
|
accounts: Arc<AccountService>,
|
||||||
info: Informant,
|
info: Informant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||||
fn initialize(&self, io: &IoContext<NetSyncMessage>) {
|
fn initialize(&self, io: &IoContext<NetSyncMessage>) {
|
||||||
io.register_timer(INFO_TIMER, 5000).expect("Error registering timer");
|
io.register_timer(INFO_TIMER, 5000).expect("Error registering timer");
|
||||||
|
io.register_timer(ACCOUNT_TICK_TIMER, ACCOUNT_TICK_MS).expect("Error registering account timer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timeout(&self, _io: &IoContext<NetSyncMessage>, timer: TimerToken) {
|
fn timeout(&self, _io: &IoContext<NetSyncMessage>, timer: TimerToken) {
|
||||||
if INFO_TIMER == timer {
|
match timer {
|
||||||
self.info.tick(&self.client, &self.sync);
|
INFO_TIMER => { self.info.tick(&self.client, &self.sync); }
|
||||||
|
ACCOUNT_TICK_TIMER => { self.accounts.tick(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ impl AccountService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Default for SecretStore {
|
impl Default for SecretStore {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
SecretStore::new()
|
SecretStore::new()
|
||||||
|
Loading…
Reference in New Issue
Block a user