Allow Poll Lifetime to be configured via CLI (#8885)

... rather than it being a hard-coded constant. fixes #5484 .
This commit is contained in:
Benjamin Kampmann
2018-06-18 13:42:54 +02:00
committed by Marek Kotewicz
parent 4ef71f8a82
commit 609d83f92c
9 changed files with 36 additions and 15 deletions

View File

@@ -65,6 +65,8 @@ pub struct EthClientOptions {
pub send_block_number_in_get_work: bool,
/// Gas Price Percentile used as default gas price.
pub gas_price_percentile: usize,
/// Set the timeout for the internal poll manager
pub poll_lifetime: u32
}
impl EthClientOptions {
@@ -83,6 +85,7 @@ impl Default for EthClientOptions {
pending_nonce_from_queue: false,
allow_pending_receipt_query: true,
send_block_number_in_get_work: true,
poll_lifetime: 60u32,
gas_price_percentile: 50,
}
}

View File

@@ -66,11 +66,11 @@ pub struct EthFilterClient<C, M> {
impl<C, M> EthFilterClient<C, M> {
/// Creates new Eth filter client.
pub fn new(client: Arc<C>, miner: Arc<M>) -> Self {
pub fn new(client: Arc<C>, miner: Arc<M>, poll_lifetime: u32) -> Self {
EthFilterClient {
client: client,
miner: miner,
polls: Mutex::new(PollManager::new()),
polls: Mutex::new(PollManager::new(poll_lifetime)),
}
}
}

View File

@@ -62,6 +62,7 @@ pub struct EthClient<T> {
accounts: Arc<AccountProvider>,
cache: Arc<Mutex<LightDataCache>>,
polls: Mutex<PollManager<PollFilter>>,
poll_lifetime: u32,
gas_price_percentile: usize,
}
@@ -92,7 +93,8 @@ impl<T> Clone for EthClient<T> {
transaction_queue: self.transaction_queue.clone(),
accounts: self.accounts.clone(),
cache: self.cache.clone(),
polls: Mutex::new(PollManager::new()),
polls: Mutex::new(PollManager::new(self.poll_lifetime)),
poll_lifetime: self.poll_lifetime,
gas_price_percentile: self.gas_price_percentile,
}
}
@@ -109,6 +111,7 @@ impl<T: LightChainClient + 'static> EthClient<T> {
accounts: Arc<AccountProvider>,
cache: Arc<Mutex<LightDataCache>>,
gas_price_percentile: usize,
poll_lifetime: u32
) -> Self {
EthClient {
sync,
@@ -117,7 +120,8 @@ impl<T: LightChainClient + 'static> EthClient<T> {
transaction_queue,
accounts,
cache,
polls: Mutex::new(PollManager::new()),
polls: Mutex::new(PollManager::new(poll_lifetime)),
poll_lifetime,
gas_price_percentile,
}
}