hopr_transport_probe/
db_proxy.rs1use 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::FoundSurb> {
26 tracing::trace!(target: "db_proxy", "Finding SURB with matcher: {:?}", matcher);
27 self.db.find_surb(matcher).await
28 }
29
30 async fn resolve_chain_key(
31 &self,
32 offchain_key: &hopr_crypto_types::types::OffchainPublicKey,
33 ) -> hopr_db_api::errors::Result<Option<hopr_primitive_types::prelude::Address>> {
34 self.db.resolve_chain_key(offchain_key).await
35 }
36}