pub struct PowRequiredEstimator { /* private fields */ }Expand description
Tracks progress across repeated calls to pow_generate_with_iteration_limit
and produces a log-friendly ETA estimate.
PoW search is a memoryless geometric process: the expected remaining attempts
is always 2^pow_required regardless of how many have already been tried.
Consequently:
ETA_remaining = 2^pow_required / rate - elapsed
std_deviation = 2^pow_required / rate (equals the mean for a geometric distribution)
best_pow_so_far is a sanity check: after n iterations the expected maximum
leading-zero count is log2(n) - 0.83. A value far below that suggests a
broken RNG or hash chain.
Implementations§
Source§impl PowRequiredEstimator
impl PowRequiredEstimator
pub fn new( started_at_millis: TimeMillis, description: &str, pow_required: Pow, ) -> Self
Sourcepub fn record_batch_and_estimate(
&mut self,
current_time_millis: TimeMillis,
iterations_in_batch: usize,
best_pow_in_batch: Pow,
) -> String
pub fn record_batch_and_estimate( &mut self, current_time_millis: TimeMillis, iterations_in_batch: usize, best_pow_in_batch: Pow, ) -> String
Record the results of one batch and return a progress string suitable for logging.
Auto Trait Implementations§
impl Freeze for PowRequiredEstimator
impl RefUnwindSafe for PowRequiredEstimator
impl Send for PowRequiredEstimator
impl Sync for PowRequiredEstimator
impl Unpin for PowRequiredEstimator
impl UnsafeUnpin for PowRequiredEstimator
impl UnwindSafe for PowRequiredEstimator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more