Struct lightning_signer::util::velocity::VelocityControl
source · pub struct VelocityControl {
pub start_sec: u64,
pub bucket_interval: u32,
pub buckets: Vec<u64>,
pub limit: u64,
}
Expand description
Limit velocity per unit time.
We track velocity in intervals instead of tracking each send, to keep storage requirements constant.
Fields§
§start_sec: u64
start second for the current velocity epoch
bucket_interval: u32
the number of seconds represented by a bucket
buckets: Vec<u64>
each bucket entry is the total velocity detected in that interval, in satoshi
limit: u64
the limit, or MAX if the control is disabled
Implementations§
source§impl VelocityControl
impl VelocityControl
sourcepub fn new_with_intervals(
limit: u64,
bucket_interval: u32,
num_buckets: usize
) -> Self
pub fn new_with_intervals( limit: u64, bucket_interval: u32, num_buckets: usize ) -> Self
Create a velocity control with arbitrary specified intervals current_sec: the current second num_buckets: how many buckets to keep track of bucket_interval: each bucket represents this number of seconds limit: the total velocity limit when summing the buckets
sourcepub fn new_unlimited(bucket_interval: u32, num_buckets: usize) -> Self
pub fn new_unlimited(bucket_interval: u32, num_buckets: usize) -> Self
Create an unlimited velocity control (i.e. no actual control)
sourcepub fn new(spec: VelocityControlSpec) -> Self
pub fn new(spec: VelocityControlSpec) -> Self
Create a velocity control with the given interval type
sourcepub fn load_from_state(
spec: VelocityControlSpec,
state: (u64, Vec<u64>)
) -> Self
pub fn load_from_state( spec: VelocityControlSpec, state: (u64, Vec<u64>) ) -> Self
Load from persistence
sourcepub fn is_unlimited(&self) -> bool
pub fn is_unlimited(&self) -> bool
Whether this instance is unlimited (no control)
Trait Implementations§
source§impl Clone for VelocityControl
impl Clone for VelocityControl
source§fn clone(&self) -> VelocityControl
fn clone(&self) -> VelocityControl
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more