poa-governance-notifications/src/main.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

2018-05-07 05:11:48 -07:00
#![feature(try_from)]
2018-04-21 09:59:11 -07:00
extern crate chrono;
extern crate clap;
extern crate dotenv;
extern crate ethabi;
extern crate ethereum_types;
extern crate hex;
extern crate jsonrpc_core;
#[macro_use] extern crate lazy_static;
extern crate lettre;
extern crate lettre_email;
2018-04-24 09:57:06 -07:00
extern crate native_tls;
2018-04-21 09:59:11 -07:00
extern crate reqwest;
extern crate serde;
extern crate serde_json;
#[macro_use] extern crate slog;
extern crate slog_term;
extern crate web3;
mod cli;
mod config;
mod logging;
mod notify;
mod rpc;
mod utils;
use config::Config;
use notify::Notifier;
use rpc::{BlockchainIter, RpcClient};
2018-04-21 09:59:11 -07:00
fn main() {
let config = Config::load();
let client = RpcClient::new(&config.endpoint);
let mut notifier = Notifier::new(&config).unwrap();
for (start_block, stop_block) in BlockchainIter::new(&client, &config) {
2018-04-21 09:59:11 -07:00
for contract in &config.contracts {
let ballot_created_logs = client
.get_ballot_created_logs(contract, start_block, stop_block)
2018-04-21 09:59:11 -07:00
.unwrap();
for log in &ballot_created_logs {
let voting_data = client.get_voting_state(contract, log.ballot_id).unwrap();
let notif = notifier.build_notification(log, &voting_data);
notifier.notify_validators(&notif);
}
}
}
}
2018-05-07 05:11:48 -07:00