Skip to content

Commit

Permalink
chore: add missing tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Feb 22, 2024
1 parent 589318d commit d99cb30
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
version: "3"

#docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

services:
database:
image: "postgres:16.2"
Expand Down
6 changes: 6 additions & 0 deletions moksha-mint/src/btconchain/lnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use fedimint_tonic_lnd::{
};
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use tokio::sync::{MappedMutexGuard, Mutex, MutexGuard};
use tracing::instrument;
use url::Url;

pub struct LndBtcOnchain(Arc<Mutex<Client>>);
Expand Down Expand Up @@ -43,6 +44,7 @@ impl LndBtcOnchain {

#[async_trait]
impl BtcOnchain for LndBtcOnchain {
#[instrument(level = "debug", skip(self), err)]
async fn is_transaction_paid(&self, txid: &str) -> Result<bool, MokshaMintError> {
let request = ListUnspentRequest {
min_confs: 0,
Expand All @@ -59,6 +61,7 @@ impl BtcOnchain for LndBtcOnchain {
.any(|utxo| utxo.outpoint.clone().unwrap().txid_str == txid && utxo.confirmations > 0))
}

#[instrument(level = "debug", skip(self), err)]
async fn is_paid(
&self,
address: &str,
Expand All @@ -80,6 +83,7 @@ impl BtcOnchain for LndBtcOnchain {
}))
}

#[instrument(level = "debug", skip(self), err)]
async fn new_address(&self) -> Result<String, MokshaMintError> {
let mut client = self.client_lock().await?;
let response = client
Expand All @@ -93,6 +97,7 @@ impl BtcOnchain for LndBtcOnchain {
Ok(response.address)
}

#[instrument(level = "debug", skip(self), err)]
async fn send_coins(
&self,
address: &str,
Expand All @@ -116,6 +121,7 @@ impl BtcOnchain for LndBtcOnchain {
})
}

#[instrument(level = "debug", skip(self), err)]
async fn estimate_fee(
&self,
address: &str,
Expand Down
19 changes: 19 additions & 0 deletions moksha-mint/src/database/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl PostgresDB {

#[async_trait]
impl Database for PostgresDB {
#[instrument(level = "debug", skip(self), err)]
async fn get_used_proofs(&self) -> Result<Proofs, MokshaMintError> {
let proofs = sqlx::query!("SELECT * FROM used_proofs")
.fetch_all(&self.pool)
Expand All @@ -69,6 +70,7 @@ impl Database for PostgresDB {
Ok(proofs.into())
}

#[instrument(level = "debug", skip(self), err)]
async fn add_used_proofs(&self, proofs: &Proofs) -> Result<(), MokshaMintError> {
for proof in proofs.proofs() {
sqlx::query!(
Expand Down Expand Up @@ -119,6 +121,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn delete_pending_invoice(&self, key: String) -> Result<(), MokshaMintError> {
sqlx::query!("DELETE FROM pending_invoices WHERE key = $1", key)
.execute(&self.pool)
Expand Down Expand Up @@ -186,6 +189,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn get_bolt11_melt_quote(&self, key: &Uuid) -> Result<Bolt11MeltQuote, MokshaMintError> {
let quote: Bolt11MeltQuote = sqlx::query!(
"SELECT id, payment_request, expiry, paid, amount, fee_reserve FROM bolt11_melt_quotes WHERE id = $1",
Expand All @@ -205,6 +209,7 @@ impl Database for PostgresDB {
Ok(quote)
}

#[instrument(level = "debug", skip(self), err)]
async fn add_bolt11_melt_quote(&self, quote: &Bolt11MeltQuote) -> Result<(), MokshaMintError> {
sqlx::query!(
"INSERT INTO bolt11_melt_quotes (id, payment_request, expiry, paid, amount, fee_reserve) VALUES ($1, $2, $3, $4, $5, $6)",
Expand All @@ -220,6 +225,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn update_bolt11_melt_quote(
&self,
quote: &Bolt11MeltQuote,
Expand All @@ -234,6 +240,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn delete_bolt11_melt_quote(
&self,
quote: &Bolt11MeltQuote,
Expand All @@ -247,6 +254,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn get_onchain_mint_quote(
&self,
key: &Uuid,
Expand All @@ -268,6 +276,8 @@ impl Database for PostgresDB {

Ok(quote)
}

#[instrument(level = "debug", skip(self), err)]
async fn add_onchain_mint_quote(
&self,
quote: &OnchainMintQuote,
Expand All @@ -285,6 +295,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn update_onchain_mint_quote(
&self,
quote: &OnchainMintQuote,
Expand All @@ -299,6 +310,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn delete_onchain_mint_quote(
&self,
quote: &OnchainMintQuote,
Expand All @@ -312,6 +324,7 @@ impl Database for PostgresDB {
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn get_onchain_melt_quote(
&self,
key: &Uuid,
Expand All @@ -334,6 +347,8 @@ impl Database for PostgresDB {

Ok(quote)
}

#[instrument(level = "debug", skip(self), err)]
async fn add_onchain_melt_quote(
&self,
quote: &OnchainMeltQuote,
Expand All @@ -352,6 +367,8 @@ impl Database for PostgresDB {
.await?;
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn update_onchain_melt_quote(
&self,
quote: &OnchainMeltQuote,
Expand All @@ -365,6 +382,8 @@ impl Database for PostgresDB {
.await?;
Ok(())
}

#[instrument(level = "debug", skip(self), err)]
async fn delete_onchain_melt_quote(
&self,
quote: &OnchainMeltQuote,
Expand Down
4 changes: 3 additions & 1 deletion moksha-mint/src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl Mint {
Ok(promises)
}

#[instrument(level = "debug", skip(self), err)]
pub async fn create_invoice(
&self,
key: String,
Expand All @@ -112,7 +113,7 @@ impl Mint {
Ok((pr, key))
}

#[instrument(level = "debug", skip(self))]
#[instrument(level = "debug", skip(self, outputs), err)]
pub async fn mint_tokens(
&self,
payment_method: PaymentMethod,
Expand Down Expand Up @@ -145,6 +146,7 @@ impl Mint {
!outputs.iter().all(move |x| uniq.insert(x.b_))
}

#[instrument(level = "debug", skip_all, err)]
pub async fn swap(
&self,
proofs: &Proofs,
Expand Down

0 comments on commit d99cb30

Please sign in to comment.