mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
CLI flag to configure tx ban duration (#11786)
* add tx-ban-seconds * fix * trigger CI * trigger CI * remove test print * Update client/cli/src/params/transaction_pool_params.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -29,11 +29,15 @@ pub struct TransactionPoolParams {
|
||||
/// Maximum number of kilobytes of all transactions stored in the pool.
|
||||
#[clap(long, value_name = "COUNT", default_value = "20480")]
|
||||
pub pool_kbytes: usize,
|
||||
|
||||
/// How long a transaction is banned for, if it is considered invalid. Defaults to 1800s.
|
||||
#[clap(long, value_name = "SECONDS")]
|
||||
pub tx_ban_seconds: Option<u64>,
|
||||
}
|
||||
|
||||
impl TransactionPoolParams {
|
||||
/// Fill the given `PoolConfiguration` by looking at the cli parameters.
|
||||
pub fn transaction_pool(&self) -> TransactionPoolOptions {
|
||||
pub fn transaction_pool(&self, is_dev: bool) -> TransactionPoolOptions {
|
||||
let mut opts = TransactionPoolOptions::default();
|
||||
|
||||
// ready queue
|
||||
@@ -45,6 +49,14 @@ impl TransactionPoolParams {
|
||||
opts.future.count = self.pool_limit / factor;
|
||||
opts.future.total_bytes = self.pool_kbytes * 1024 / factor;
|
||||
|
||||
opts.ban_time = if let Some(ban_seconds) = self.tx_ban_seconds {
|
||||
std::time::Duration::from_secs(ban_seconds)
|
||||
} else if is_dev {
|
||||
std::time::Duration::from_secs(0)
|
||||
} else {
|
||||
std::time::Duration::from_secs(30 * 60)
|
||||
};
|
||||
|
||||
opts
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user