pub struct TipWatcher { /* private fields */ }Implementations§
Source§impl TipWatcher
impl TipWatcher
pub async fn start_poll<S: TipSource + 'static>( source: Arc<S>, poll_interval: Duration, ) -> Result<Self>
Sourcepub async fn start_zmq<S: TipSource + 'static>(
source: Arc<S>,
zmq_endpoint: &str,
reconcile_interval: Duration,
) -> Result<Self>
pub async fn start_zmq<S: TipSource + 'static>( source: Arc<S>, zmq_endpoint: &str, reconcile_interval: Duration, ) -> Result<Self>
Start a watcher that follows the chain tip of source.
The watcher has two sources of tip updates and trusts both.
bitcoind announces the hash of each new block on zmq_endpoint.
The watcher makes this hash the new tip and increases the height
by one. No backend call is necessary for this update.
After each reconcile_interval, the watcher reads the tip from
source. A changed value becomes the new tip. This read corrects
the tip after a lost notification or a reorg.
pub fn tip(&self) -> BlockRef
Sourcepub fn subscribe(&self) -> TipSubscription
pub fn subscribe(&self) -> TipSubscription
Subscribe to tip changes.
The subscription keeps the watcher task alive.
Sourcepub async fn wait_for_height(&self, height: u32) -> Result<BlockRef>
pub async fn wait_for_height(&self, height: u32) -> Result<BlockRef>
Wait until the tip reaches the given height.
pub fn stop(&self)
Trait Implementations§
Source§impl Clone for TipWatcher
impl Clone for TipWatcher
Source§fn clone(&self) -> TipWatcher
fn clone(&self) -> TipWatcher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TipWatcher
impl !UnwindSafe for TipWatcher
impl Freeze for TipWatcher
impl Send for TipWatcher
impl Sync for TipWatcher
impl Unpin for TipWatcher
impl UnsafeUnpin for TipWatcher
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request