hopr_transport_probe/
db_proxy.rs

1use async_trait::async_trait;
2use hopr_db_api::{protocol::HoprDbProtocolOperations, resolver::HoprDbResolverOperations};
3
4use crate::traits::DbOperations;
5
6#[derive(Debug, Clone)]
7pub struct DbProxy<T> {
8    db: T,
9}
10
11impl<T> DbProxy<T> {
12    pub fn new(db: T) -> Self {
13        Self { db }
14    }
15}
16
17#[async_trait]
18impl<T> DbOperations for DbProxy<T>
19where
20    T: HoprDbResolverOperations + HoprDbProtocolOperations + std::fmt::Debug + Clone + Send + Sync + 'static,
21{
22    async fn find_surb(
23        &self,
24        matcher: hopr_network_types::types::SurbMatcher,
25    ) -> hopr_db_api::errors::Result<(hopr_db_api::protocol::HoprSenderId, hopr_db_api::protocol::HoprSurb)> {
26        self.db.find_surb(matcher).await
27    }
28
29    async fn resolve_chain_key(
30        &self,
31        offchain_key: &hopr_crypto_types::types::OffchainPublicKey,
32    ) -> hopr_db_api::errors::Result<Option<hopr_primitive_types::prelude::Address>> {
33        self.db.resolve_chain_key(offchain_key).await
34    }
35}