pub struct GenericStore<S, R, F>where
S: Store + Send + Sync + 'static,
R: SignalingTransport + Send + Sync + 'static,
F: PeerLinkFactory + Send + Sync + 'static,{ /* private fields */ }Expand description
Generic mesh store that works with any storage backend and transport implementation.
This is the shared code between production and simulation.
- Production:
GenericStore<LmdbStore, NostrSignalingTransport, WebRtcPeerLinkFactory> - Simulation:
GenericStore<MemoryStore, MockSignalingTransport, MockConnectionFactory>
Implementations§
Source§impl<S, R, F> GenericStore<S, R, F>where
S: Store + Send + Sync + 'static,
R: SignalingTransport + Send + Sync + 'static,
F: PeerLinkFactory + Send + Sync + 'static,
impl<S, R, F> GenericStore<S, R, F>where
S: Store + Send + Sync + 'static,
R: SignalingTransport + Send + Sync + 'static,
F: PeerLinkFactory + Send + Sync + 'static,
Sourcepub fn new(
local_store: Arc<S>,
signaling: Arc<MeshRouter<R, F>>,
request_timeout: Duration,
debug: bool,
) -> Self
pub fn new( local_store: Arc<S>, signaling: Arc<MeshRouter<R, F>>, request_timeout: Duration, debug: bool, ) -> Self
Create a new generic store
Sourcepub fn new_with_routing(
local_store: Arc<S>,
signaling: Arc<MeshRouter<R, F>>,
request_timeout: Duration,
debug: bool,
routing: GenericStoreRoutingConfig,
) -> Self
pub fn new_with_routing( local_store: Arc<S>, signaling: Arc<MeshRouter<R, F>>, request_timeout: Duration, debug: bool, routing: GenericStoreRoutingConfig, ) -> Self
Create a new generic store with explicit routing configuration.
Sourcepub async fn start(&self) -> Result<(), TransportError>
pub async fn start(&self) -> Result<(), TransportError>
Start the store (begin listening for messages)
Sourcepub async fn process_signaling(
&self,
msg: SignalingMessage,
) -> Result<(), TransportError>
pub async fn process_signaling( &self, msg: SignalingMessage, ) -> Result<(), TransportError>
Process incoming signaling message
Sourcepub fn signaling(&self) -> &Arc<MeshRouter<R, F>>
pub fn signaling(&self) -> &Arc<MeshRouter<R, F>>
Get signaling manager reference
Sourcepub async fn peer_count(&self) -> usize
pub async fn peer_count(&self) -> usize
Get peer count
Sourcepub async fn needs_peers(&self) -> bool
pub async fn needs_peers(&self) -> bool
Check if we need more peers
Sourcepub async fn send_hello(&self) -> Result<(), TransportError>
pub async fn send_hello(&self) -> Result<(), TransportError>
Re-broadcast hello to refresh discovery as topology changes.
Sourcepub async fn record_cashu_payment_for_peer(
&self,
peer_id: &str,
amount_sat: u64,
)
pub async fn record_cashu_payment_for_peer( &self, peer_id: &str, amount_sat: u64, )
Apply an out-of-band payment credit to a peer’s routing priority.
Sourcepub async fn record_cashu_receipt_from_peer(
&self,
peer_id: &str,
amount_sat: u64,
)
pub async fn record_cashu_receipt_from_peer( &self, peer_id: &str, amount_sat: u64, )
Record a post-delivery payment we received from a peer.
Sourcepub async fn record_cashu_payment_default_from_peer(&self, peer_id: &str)
pub async fn record_cashu_payment_default_from_peer(&self, peer_id: &str)
Record that a peer failed to pay after we delivered successfully.
Sourcepub async fn peer_metadata_snapshot(&self) -> PeerMetadataSnapshot
pub async fn peer_metadata_snapshot(&self) -> PeerMetadataSnapshot
Export live peer metadata for inspection/debugging.
Sourcepub async fn persist_peer_metadata(&self) -> Result<Hash, StoreError>
pub async fn persist_peer_metadata(&self) -> Result<Hash, StoreError>
Snapshot current peer metadata and persist it into local_store.
Uses content-addressed storage for the snapshot body and a reserved mutable pointer slot for the “latest snapshot hash”.
Sourcepub async fn load_peer_metadata(&self) -> Result<bool, StoreError>
pub async fn load_peer_metadata(&self) -> Result<bool, StoreError>
Load persisted peer metadata from local_store if available.
Sourcepub async fn get_with_quote(
&self,
hash: &Hash,
payment_sat: u64,
quote_ttl: Duration,
) -> Result<Option<Vec<u8>>, StoreError>
pub async fn get_with_quote( &self, hash: &Hash, payment_sat: u64, quote_ttl: Duration, ) -> Result<Option<Vec<u8>>, StoreError>
Request data from peers after negotiating a paid quote.
If quote negotiation fails or the quoted peer does not deliver, the store falls back to the normal unpaid retrieval path to preserve liveness.
Sourcepub async fn handle_data_message(&self, from_peer: &str, data: &[u8])
pub async fn handle_data_message(&self, from_peer: &str, data: &[u8])
Handle incoming data message
Trait Implementations§
Source§impl<S, R, F> Store for GenericStore<S, R, F>where
S: Store + Send + Sync + 'static,
R: SignalingTransport + Send + Sync + 'static,
F: PeerLinkFactory + Send + Sync + 'static,
impl<S, R, F> Store for GenericStore<S, R, F>where
S: Store + Send + Sync + 'static,
R: SignalingTransport + Send + Sync + 'static,
F: PeerLinkFactory + Send + Sync + 'static,
Source§fn put<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
hash: Hash,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 Hash,
) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn put_many<'life0, 'async_trait>(
&'life0 self,
items: Vec<([u8; 32], Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn put_many<'life0, 'async_trait>(
&'life0 self,
items: Vec<([u8; 32], Vec<u8>)>,
) -> Pin<Box<dyn Future<Output = Result<usize, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn set_max_bytes(&self, _max: u64)
fn set_max_bytes(&self, _max: u64)
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreStats> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreStats> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn evict_if_needed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn evict_if_needed<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn unpin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unpin<'life0, 'life1, 'async_trait>(
&'life0 self,
_hash: &'life1 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations§
impl<S, R, F> !Freeze for GenericStore<S, R, F>
impl<S, R, F> !RefUnwindSafe for GenericStore<S, R, F>
impl<S, R, F> Send for GenericStore<S, R, F>
impl<S, R, F> Sync for GenericStore<S, R, F>
impl<S, R, F> Unpin for GenericStore<S, R, F>
impl<S, R, F> UnsafeUnpin for GenericStore<S, R, F>
impl<S, R, F> !UnwindSafe for GenericStore<S, R, F>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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