Removed trailing whitespace.

This commit is contained in:
DrPeterVanNostrand 2018-12-11 14:54:31 +00:00
parent 7d2f2ef8b9
commit 3e10c68293
8 changed files with 32 additions and 32 deletions

View File

@ -64,7 +64,7 @@ impl<'a> BlockchainIter<'a> {
impl<'a> Iterator for BlockchainIter<'a> {
type Item = Result<(BlockNumber, BlockNumber)>;
fn next(&mut self) -> Option<Self::Item> {
fn next(&mut self) -> Option<Self::Item> {
if self.on_first_iteration {
self.on_first_iteration = false;
} else {

View File

@ -39,7 +39,7 @@ impl Cli {
pub fn sokol(&self) -> bool {
self.0.is_present("sokol")
}
pub fn keys(&self) -> bool {
self.0.is_present("keys")
}
@ -47,7 +47,7 @@ impl Cli {
pub fn threshold(&self) -> bool {
self.0.is_present("threshold")
}
pub fn proxy(&self) -> bool {
self.0.is_present("proxy")
}
@ -63,7 +63,7 @@ impl Cli {
pub fn v2(&self) -> bool {
self.0.is_present("v2")
}
pub fn earliest(&self) -> bool {
self.0.is_present("earliest")
}

View File

@ -134,8 +134,8 @@ impl RpcClient {
from: None,
gas: None,
gas_price: None,
value: None,
};
value: None,
};
let rpc_method_params = vec![
json::to_value(function_call_request).unwrap(),
json::to_value(BlockNumber::Latest).unwrap(),
@ -183,8 +183,8 @@ impl RpcClient {
from: None,
gas: None,
gas_price: None,
value: None,
};
value: None,
};
let rpc_method_params = vec![
json::to_value(function_call_request).unwrap(),
json::to_value(BlockNumber::Latest).unwrap(),

View File

@ -59,7 +59,7 @@ impl ContractType {
}
}
fn abi_file_name(&self) -> &str {
fn abi_file_name(&self) -> &str {
match self {
ContractType::Keys => "VotingToChangeKeys.abi.json",
ContractType::Threshold => "VotingToChangeMinThreshold.abi.json",
@ -112,7 +112,7 @@ impl PoaContract {
if contract_type == ContractType::Emission && version == ContractVersion::V1 {
return Err(Error::EmissionFundsV1ContractDoesNotExist);
}
let addr_env_var = format!(
"{}_CONTRACT_ADDRESS_{}_{:?}",
contract_type.uppercase(),
@ -134,7 +134,7 @@ impl PoaContract {
version.lowercase(),
contract_type.abi_file_name(),
);
let abi_file = File::open(&abi_path)
.map_err(|_| Error::MissingAbiFile(abi_path.clone()))?;
@ -195,7 +195,7 @@ impl Config {
let endpoint_env_var = format!("{}_RPC_ENDPOINT", network.uppercase());
let endpoint = env::var(&endpoint_env_var)
.map_err(|_| Error::MissingEnvVar(endpoint_env_var))?;
let version = if cli.v1() == cli.v2(){
return Err(Error::MustSpecifyOneCliArgument("`--v1` or `--v2`".into()));
} else if cli.v1(){
@ -203,7 +203,7 @@ impl Config {
} else {
ContractVersion::V2
};
let mut contracts = vec![];
if cli.keys() {
let keys = PoaContract::read(
@ -243,7 +243,7 @@ impl Config {
));
}
let start_block = if cli.multiple_start_blocks_specified() {
let start_block = if cli.multiple_start_blocks_specified() {
return Err(Error::MustSpecifyOneCliArgument(
"`--earliest` or `--latest` or `--start-block` or `--tail`".into()
));
@ -268,7 +268,7 @@ impl Config {
};
let email_notifications = cli.email();
let email_recipients: Vec<String> = env::var("EMAIL_RECIPIENTS")
.map_err(|_| Error::MissingEnvVar("EMAIL_RECIPIENTS".into()))?
.split(',')
@ -363,7 +363,7 @@ mod tests {
use super::super::tests::setup;
use super::{ContractType, ContractVersion, PoaContract, Network};
const CONTRACT_TYPES: [ContractType; 4] = [
const CONTRACT_TYPES: [ContractType; 4] = [
ContractType::Keys,
ContractType::Threshold,
ContractType::Proxy,

View File

@ -20,7 +20,7 @@ const MAX_LOG_FILE_SIZE_MB: usize = 4;
const MAX_LOG_FILE_SIZE_BYTES: usize = MAX_LOG_FILE_SIZE_MB * 1024 * 1024;
// We dont want to check the log file's size after every log that is written, this constant states
// "after this many logs have been written, check the log file's size". This value assumes an
// average log is around 100 ASCII characters (bytes) long.
// average log is around 100 ASCII characters (bytes) long.
const INITIAL_CHECK_FILE_SIZE_AT: usize = MAX_LOG_FILE_SIZE_BYTES / 100;
fn create_logs_dir() {
@ -84,7 +84,7 @@ impl LogFile {
fn now() -> Self {
LogFile(Utc::now())
}
fn from_file_name(file_name: &str) -> Result<Self, ()> {
if let Ok(dt) = Utc.datetime_from_str(file_name, FILE_NAME_DATE_FORMAT) {
Ok(LogFile(dt))
@ -140,7 +140,7 @@ impl Logger {
check_file_size_at: INITIAL_CHECK_FILE_SIZE_AT,
}
}
fn logging_to_file(&self) -> bool {
!self.log_files.is_empty()
}
@ -152,7 +152,7 @@ impl Logger {
let file_size = get_file_size_in_bytes(&path);
if file_size >= MAX_LOG_FILE_SIZE_BYTES {
return true;
}
}
let avg_bytes_per_log = file_size / self.log_count;
let remaining_bytes = MAX_LOG_FILE_SIZE_BYTES - file_size;
let remaining_logs = remaining_bytes / avg_bytes_per_log;
@ -180,7 +180,7 @@ impl Logger {
info!(&self.logger, "starting poagov...");
self.increment_log_count();
}
pub fn log_ctrlc(&mut self) {
warn!(&self.logger, "recieved ctrl-c signal, gracefully shutting down...");
self.increment_log_count();
@ -195,7 +195,7 @@ impl Logger {
info!(&self.logger, "governance notification\n{}", notif.email_text());
self.increment_log_count();
}
pub fn log_notification(&mut self, notif: &Notification) {
let ballot_created_log = notif.log();
info!(
@ -207,12 +207,12 @@ impl Logger {
);
self.increment_log_count();
}
pub fn log_failed_to_build_email(&mut self, e: Error) {
warn!(&self.logger, "failed to build email"; "error" => format!("{:?}", e));
self.increment_log_count();
}
pub fn log_failed_to_send_email(&mut self, recipient: &str, e: Error) {
warn!(
&self.logger,
@ -227,7 +227,7 @@ impl Logger {
info!(&self.logger, "email sent"; "to" => recipient);
self.increment_log_count();
}
pub fn log_reached_notification_limit(&mut self, notification_limit: usize) {
warn!(
&self.logger,

View File

@ -48,7 +48,7 @@ fn load_env_file() {
fn set_ctrlc_handler(logger: Arc<Mutex<Logger>>) -> Result<Arc<AtomicBool>> {
let running = Arc::new(AtomicBool::new(true));
let result = Ok(running.clone());
let result = Ok(running.clone());
ctrlc::set_handler(move || {
logger.lock().unwrap().log_ctrlc();
running.store(false, Ordering::SeqCst);
@ -58,7 +58,7 @@ fn set_ctrlc_handler(logger: Arc<Mutex<Logger>>) -> Result<Arc<AtomicBool>> {
fn main() -> Result<()> {
load_env_file();
let cli = Cli::parse();
let config = Config::new(&cli)?;
let logger = Arc::new(Mutex::new(Logger::new(&config)));
@ -79,7 +79,7 @@ fn main() -> Result<()> {
start_block,
stop_block,
)?;
for log in ballot_created_logs.into_iter() {
for log in ballot_created_logs.into_iter() {
let notification = if contract.version == ContractVersion::V1 {
let voting_state = client.get_voting_state(contract, log.ballot_id)?;
Notification::from_voting_state(&config, log, voting_state)

View File

@ -62,14 +62,14 @@ impl From<ProxyVotingState> for VotingState {
}
impl VotingState {
pub fn contract_name(&self) -> String {
pub fn contract_name(&self) -> String {
match self {
VotingState::Keys(_) => "VotingToChangeKeys.sol".into(),
VotingState::Threshold(_) => "VotingToChangeMinThreshold.sol".into(),
VotingState::Proxy(_) => "VotingToChangeProxyAddress.sol".into(),
}
}
pub fn email_text(&self) -> String {
match self {
VotingState::Keys(state) => state.email_text(),

View File

@ -37,7 +37,7 @@ impl From<EmissionBallotInfo> for BallotInfo {
}
impl BallotInfo {
pub fn contract_name(&self) -> String {
pub fn contract_name(&self) -> String {
match self {
BallotInfo::Keys(_) => "VotingToChangeKeys.sol".into(),
BallotInfo::Threshold(_) => "VotingToChangeMinThreshold.sol".into(),
@ -46,7 +46,7 @@ impl BallotInfo {
}
}
pub fn email_text(&self) -> String {
pub fn email_text(&self) -> String {
match self {
BallotInfo::Keys(info) => info.email_text(),
BallotInfo::Threshold(info) => info.email_text(),