xenith-sync 0.1.0

State sync engine for xenith — push, read, and resolve across chains
Documentation
use xenith_core::{ChainId, StateKey};

/// Handle to a running subscription polling loop.
///
/// Dropping or calling [`cancel`][SubscriptionHandle::cancel] stops the loop.
pub struct SubscriptionHandle {
    pub key: StateKey,
    pub source_chain: ChainId,
    abort_handle: tokio::task::AbortHandle,
}

impl SubscriptionHandle {
    pub(crate) fn new(
        key: StateKey,
        source_chain: ChainId,
        abort_handle: tokio::task::AbortHandle,
    ) -> Self {
        Self {
            key,
            source_chain,
            abort_handle,
        }
    }

    /// Stop the subscription polling loop.
    pub fn cancel(self) {
        self.abort_handle.abort();
    }
}