pub struct ReplicationEngine { /* private fields */ }Expand description
The replication engine manages all replication background tasks and state.
Implementations§
Source§impl ReplicationEngine
impl ReplicationEngine
Sourcepub async fn new(
config: ReplicationConfig,
p2p_node: Arc<P2PNode>,
storage: Arc<LmdbStorage>,
payment_verifier: Arc<PaymentVerifier>,
root_dir: &Path,
fresh_write_rx: UnboundedReceiver<FreshWriteEvent>,
shutdown: CancellationToken,
) -> Result<Self>
pub async fn new( config: ReplicationConfig, p2p_node: Arc<P2PNode>, storage: Arc<LmdbStorage>, payment_verifier: Arc<PaymentVerifier>, root_dir: &Path, fresh_write_rx: UnboundedReceiver<FreshWriteEvent>, shutdown: CancellationToken, ) -> Result<Self>
Create a new replication engine.
§Errors
Returns an error if the PaidList LMDB environment cannot be opened
or if the configuration fails validation.
Sourcepub fn start(&mut self, dht_events: Receiver<DhtNetworkEvent>)
pub fn start(&mut self, dht_events: Receiver<DhtNetworkEvent>)
Start all background tasks.
dht_events must be subscribed before P2PNode::start() so that
the BootstrapComplete event emitted during DHT bootstrap is not
missed by the bootstrap-sync gate.
Sourcepub async fn is_bootstrapping(&self) -> bool
pub async fn is_bootstrapping(&self) -> bool
Returns true if the node is still in the replication bootstrap phase.
During bootstrap, audit challenges return Bootstrapping instead of
digests, and neighbor sync responses carry bootstrapping: true.
Sourcepub async fn wait_for_bootstrap_complete(&self, timeout: Duration) -> bool
pub async fn wait_for_bootstrap_complete(&self, timeout: Duration) -> bool
Wait until the replication bootstrap phase completes.
Returns immediately if bootstrap has already completed. Useful for readiness probes, health checks, and test harnesses that need the node to be fully operational before proceeding.
Returns true if bootstrap completed within the timeout, false
if the timeout elapsed first.
Sourcepub async fn shutdown(&mut self)
pub async fn shutdown(&mut self)
Cancel all background tasks and wait for them to terminate.
This must be awaited before dropping the engine when the caller needs
the Arc<LmdbStorage> references held by background tasks to be
released (e.g. before reopening the same LMDB environment).
Sourcepub fn trigger_neighbor_sync(&self)
pub fn trigger_neighbor_sync(&self)
Trigger an early neighbor sync round.
Useful after topology changes (new nodes joining, network heal after partition) when the caller wants replication to converge faster than the regular 10-20 minute cadence.
Sourcepub async fn replicate_fresh(
&self,
key: &XorName,
data: &[u8],
proof_of_payment: &[u8],
)
pub async fn replicate_fresh( &self, key: &XorName, data: &[u8], proof_of_payment: &[u8], )
Execute fresh replication for a newly stored record.
Auto Trait Implementations§
impl Freeze for ReplicationEngine
impl !RefUnwindSafe for ReplicationEngine
impl Send for ReplicationEngine
impl Sync for ReplicationEngine
impl Unpin for ReplicationEngine
impl UnsafeUnpin for ReplicationEngine
impl !UnwindSafe for ReplicationEngine
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
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>
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>
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