pub struct MultiRelayBlobService<S: BlobStorage> {
relay_services: Arc<RwLock<HashMap<KeyId, Arc<dyn BlobStore>>>>,
storage: Arc<S>,
}Expand description
Multi-relay blob service that manages blob uploads across multiple relays and tracks upload status using persistent storage
Fields§
§relay_services: Arc<RwLock<HashMap<KeyId, Arc<dyn BlobStore>>>>Map of relay ID to blob service for that relay (thread-safe)
storage: Arc<S>Storage for tracking blob upload status
Implementations§
Source§impl<S: BlobStorage> MultiRelayBlobService<S>
impl<S: BlobStorage> MultiRelayBlobService<S>
pub fn new_with_relays( storage: Arc<S>, relay_services: impl IntoIterator<Item = (KeyId, Arc<dyn BlobStore>)>, ) -> Self
Sourcepub async fn add_relay(&self, relay_id: KeyId, service: Arc<dyn BlobStore>)
pub async fn add_relay(&self, relay_id: KeyId, service: Arc<dyn BlobStore>)
Add a relay blob service
Sourcepub async fn remove_relay(&self, relay_id: &KeyId) -> Option<Arc<dyn BlobStore>>
pub async fn remove_relay(&self, relay_id: &KeyId) -> Option<Arc<dyn BlobStore>>
Remove a relay blob service
Sourcepub async fn get_relay_ids(&self) -> Vec<KeyId>
pub async fn get_relay_ids(&self) -> Vec<KeyId>
Get all configured relay IDs
Sourcepub async fn is_blob_uploaded_to_relay(
&self,
blob_hash: &BlobId,
relay_id: &KeyId,
) -> Result<bool, BlobError>
pub async fn is_blob_uploaded_to_relay( &self, blob_hash: &BlobId, relay_id: &KeyId, ) -> Result<bool, BlobError>
Check if a blob has been uploaded to a specific relay
Sourcepub async fn get_blob_upload_status(
&self,
blob_hash: &BlobId,
) -> Result<Vec<BlobUploadStatus>, BlobError>
pub async fn get_blob_upload_status( &self, blob_hash: &BlobId, ) -> Result<Vec<BlobUploadStatus>, BlobError>
Get upload status for a blob across all relays
Sourcepub async fn upload_blob_to_relay(
&self,
blob: &[u8],
relay_id: &KeyId,
) -> Result<BlobId, BlobError>
pub async fn upload_blob_to_relay( &self, blob: &[u8], relay_id: &KeyId, ) -> Result<BlobId, BlobError>
Upload a blob to a specific relay and track the upload
async fn upload_blob_to_single_relay_and_mark_as_uploaded( blob: &[u8], service: Arc<dyn BlobStore>, relay_id: &KeyId, storage: Arc<S>, ) -> Result<BlobId, BlobError>
Sourcepub async fn upload_blob_to_all_relays(
&self,
blob: &[u8],
) -> Result<HashMap<KeyId, Result<BlobId, BlobError>>, BlobError>
pub async fn upload_blob_to_all_relays( &self, blob: &[u8], ) -> Result<HashMap<KeyId, Result<BlobId, BlobError>>, BlobError>
Upload a blob to all configured relays (in parallel)
Sourcepub async fn upload_blob_to_missing_relays(
&self,
blob: &[u8],
) -> Result<HashMap<KeyId, Result<BlobId, BlobError>>, BlobError>
pub async fn upload_blob_to_missing_relays( &self, blob: &[u8], ) -> Result<HashMap<KeyId, Result<BlobId, BlobError>>, BlobError>
Upload a blob to relays where it hasn’t been uploaded yet (in parallel)
Sourcepub async fn download_blob_from_any_relay(
&self,
blob_hash: &BlobId,
) -> Result<Vec<u8>, BlobError>
pub async fn download_blob_from_any_relay( &self, blob_hash: &BlobId, ) -> Result<Vec<u8>, BlobError>
Download a blob from any available relay (tries relays in order)
Trait Implementations§
Source§impl<S: BlobStorage> BlobStore for MultiRelayBlobService<S>
impl<S: BlobStorage> BlobStore for MultiRelayBlobService<S>
Auto Trait Implementations§
impl<S> Freeze for MultiRelayBlobService<S>
impl<S> !RefUnwindSafe for MultiRelayBlobService<S>
impl<S> Send for MultiRelayBlobService<S>
impl<S> Sync for MultiRelayBlobService<S>
impl<S> Unpin for MultiRelayBlobService<S>
impl<S> !UnwindSafe for MultiRelayBlobService<S>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Mutably borrows from an owned value. Read more