pub struct MailboxNode {
pub identity: Arc<Identity>,
pub storage: Arc<SledMailboxStore>,
pub max_storage_per_user: usize,
pub retention_period: Duration,
}Expand description
Represents a mailbox node in the network.
A mailbox node stores messages for other peers and forwards them upon request.
Fields§
§identity: Arc<Identity>The identity of the mailbox node.
storage: Arc<SledMailboxStore>The storage for mailbox messages.
max_storage_per_user: usizeThe maximum number of messages to store per user.
retention_period: DurationThe duration for which messages are retained.
Implementations§
Source§impl MailboxNode
impl MailboxNode
Sourcepub fn new(
identity: Arc<Identity>,
db: Db,
encryption: Option<StorageEncryption>,
max_storage_per_user: usize,
retention_period: Duration,
) -> Result<Self>
pub fn new( identity: Arc<Identity>, db: Db, encryption: Option<StorageEncryption>, max_storage_per_user: usize, retention_period: Duration, ) -> Result<Self>
Creates a new MailboxNode.
§Arguments
identity- The identity of the node.db- The database instance for storing mailbox data.encryption- The encryption key for the storage.max_storage_per_user- The maximum number of messages to store per user.retention_period- The duration for which messages are retained.
§Errors
This function will return an error if the mailbox storage cannot be created.
Sourcepub async fn run_with_network(
&mut self,
network_layer: NetworkLayer,
) -> Result<()>
pub async fn run_with_network( &mut self, network_layer: NetworkLayer, ) -> Result<()>
Runs the mailbox node with the given network layer.
This function starts the mailbox node and its associated tasks, such as the cleanup task and the network event loop.
§Arguments
network_layer- The network layer to use for communication.
§Errors
This function will return an error if the mailbox node fails to run.
Sourceasync fn run_mailbox_network_loop(
network_layer: NetworkLayer,
_storage: Arc<SledMailboxStore>,
) -> Result<()>
async fn run_mailbox_network_loop( network_layer: NetworkLayer, _storage: Arc<SledMailboxStore>, ) -> Result<()>
Runs the network event loop for the mailbox node.
Sourceasync fn cleanup_task(
storage: Arc<SledMailboxStore>,
retention_period: Duration,
)
async fn cleanup_task( storage: Arc<SledMailboxStore>, retention_period: Duration, )
Periodically cleans up expired messages from the storage.
Sourcepub fn get_stats(&self) -> MailboxStats
pub fn get_stats(&self) -> MailboxStats
Returns statistics about the mailbox node.
Auto Trait Implementations§
impl Freeze for MailboxNode
impl !RefUnwindSafe for MailboxNode
impl Send for MailboxNode
impl Sync for MailboxNode
impl Unpin for MailboxNode
impl !UnwindSafe for MailboxNode
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