pub struct TaskNewHeader { /* private fields */ }Expand description
Background task that polls for new block headers.
When a new block is detected, it queues the header and waits one cycle. If the header remains the chain tip after a full cycle (no further new blocks), it triggers proof checking by setting the shared check_now flag.
This aging pattern avoids chasing proofs during rapid block reorgs.
Implementations§
Source§impl TaskNewHeader
impl TaskNewHeader
Sourcepub fn new(
storage: WalletStorageManager,
services: Arc<dyn WalletServices>,
check_now: Arc<AtomicBool>,
) -> Self
pub fn new( storage: WalletStorageManager, services: Arc<dyn WalletServices>, check_now: Arc<AtomicBool>, ) -> Self
Create a new TaskNewHeader with default intervals.
Sourcepub fn with_trigger_msecs(
storage: WalletStorageManager,
services: Arc<dyn WalletServices>,
check_now: Arc<AtomicBool>,
trigger_msecs: u64,
) -> Self
pub fn with_trigger_msecs( storage: WalletStorageManager, services: Arc<dyn WalletServices>, check_now: Arc<AtomicBool>, trigger_msecs: u64, ) -> Self
Create with a custom trigger interval.
Trait Implementations§
Source§impl WalletMonitorTask for TaskNewHeader
impl WalletMonitorTask for TaskNewHeader
Source§fn trigger(&mut self, now_msecs_since_epoch: u64) -> bool
fn trigger(&mut self, now_msecs_since_epoch: u64) -> bool
Return true if
run_task needs to be called now.
This is NOT async – it must be a fast, synchronous check.Source§fn run_task<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<String, WalletError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_task<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<String, WalletError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the task’s work. Returns a log string describing what was done.
Source§fn async_setup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_setup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Override to handle async task setup configuration.
Called before the first call to
trigger.Auto Trait Implementations§
impl !Freeze for TaskNewHeader
impl !RefUnwindSafe for TaskNewHeader
impl Send for TaskNewHeader
impl Sync for TaskNewHeader
impl Unpin for TaskNewHeader
impl UnsafeUnpin for TaskNewHeader
impl !UnwindSafe for TaskNewHeader
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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