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

@@ -732,6 +732,10 @@ usage! {
"--gas-price-percentile=[PCT]",
"Set PCT percentile gas price value from last 100 blocks as default gas price when sending transactions.",
ARG arg_poll_lifetime: (u32) = 60u32, or |c: &Config| c.mining.as_ref()?.poll_lifetime.clone(),
"--poll-lifetime=[S]",
"Set the lifetime of the internal index filter to S seconds.",
ARG arg_author: (Option<String>) = None, or |c: &Config| c.mining.as_ref()?.author.clone(),
"--author=[ADDRESS]",
"Specify the block author (aka \"coinbase\") address for sending block rewards from sealed blocks. NOTE: MINING WILL NOT WORK WITHOUT THIS OPTION.", // Sealing/Mining Option
@@ -1241,6 +1245,7 @@ struct Mining {
relay_set: Option<String>,
min_gas_price: Option<u64>,
gas_price_percentile: Option<usize>,
poll_lifetime: Option<u32>,
usd_per_tx: Option<String>,
usd_per_eth: Option<String>,
price_update_period: Option<String>,
@@ -1664,6 +1669,7 @@ mod tests {
arg_min_gas_price: Some(0u64),
arg_usd_per_tx: "0.0001".into(),
arg_gas_price_percentile: 50usize,
arg_poll_lifetime: 60u32,
arg_usd_per_eth: "auto".into(),
arg_price_update_period: "hourly".into(),
arg_gas_floor_target: "4700000".into(),
@@ -1924,6 +1930,7 @@ mod tests {
relay_set: None,
min_gas_price: None,
gas_price_percentile: None,
poll_lifetime: None,
usd_per_tx: None,
usd_per_eth: None,
price_update_period: Some("hourly".into()),

View File

@@ -356,6 +356,7 @@ impl Configuration {
logger_config: logger_config.clone(),
miner_options: self.miner_options()?,
gas_price_percentile: self.args.arg_gas_price_percentile,
poll_lifetime: self.args.arg_poll_lifetime,
ntp_servers: self.ntp_servers(),
ws_conf: ws_conf,
http_conf: http_conf,
@@ -1398,6 +1399,7 @@ mod tests {
logger_config: Default::default(),
miner_options: Default::default(),
gas_price_percentile: 50,
poll_lifetime: 60,
ntp_servers: vec![
"0.parity.pool.ntp.org:123".into(),
"1.parity.pool.ntp.org:123".into(),

View File

@@ -235,6 +235,7 @@ pub struct FullDependencies {
pub remote: parity_reactor::Remote,
pub whisper_rpc: Option<::whisper::RpcFactory>,
pub gas_price_percentile: usize,
pub poll_lifetime: u32,
}
impl FullDependencies {
@@ -288,12 +289,13 @@ impl FullDependencies {
allow_pending_receipt_query: !self.geth_compatibility,
send_block_number_in_get_work: !self.geth_compatibility,
gas_price_percentile: self.gas_price_percentile,
poll_lifetime: self.poll_lifetime
}
);
handler.extend_with(client.to_delegate());
if !for_generic_pubsub {
let filter_client = EthFilterClient::new(self.client.clone(), self.miner.clone());
let filter_client = EthFilterClient::new(self.client.clone(), self.miner.clone(), self.poll_lifetime);
handler.extend_with(filter_client.to_delegate());
add_signing_methods!(EthSigning, handler, self, nonces.clone());
@@ -447,6 +449,7 @@ pub struct LightDependencies<T> {
pub whisper_rpc: Option<::whisper::RpcFactory>,
pub private_tx_service: Option<Arc<PrivateTransactionManager>>,
pub gas_price_percentile: usize,
pub poll_lifetime: u32,
}
impl<C: LightChainClient + 'static> LightDependencies<C> {
@@ -504,6 +507,7 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
self.secret_store.clone(),
self.cache.clone(),
self.gas_price_percentile,
self.poll_lifetime,
);
handler.extend_with(Eth::to_delegate(client.clone()));

View File

@@ -90,6 +90,7 @@ pub struct RunCmd {
pub logger_config: LogConfig,
pub miner_options: MinerOptions,
pub gas_price_percentile: usize,
pub poll_lifetime: u32,
pub ntp_servers: Vec<String>,
pub ws_conf: rpc::WsConfiguration,
pub http_conf: rpc::HttpConfiguration,
@@ -350,6 +351,7 @@ fn execute_light_impl(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<Runnin
whisper_rpc: whisper_factory,
private_tx_service: None, //TODO: add this to client.
gas_price_percentile: cmd.gas_price_percentile,
poll_lifetime: cmd.poll_lifetime
});
let dependencies = rpc::Dependencies {
@@ -779,6 +781,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
whisper_rpc: whisper_factory,
private_tx_service: Some(private_tx_service.clone()),
gas_price_percentile: cmd.gas_price_percentile,
poll_lifetime: cmd.poll_lifetime,
});
let dependencies = rpc::Dependencies {