Cesar Rodas 4 months ago
parent
commit
601f996252
3 changed files with 21 additions and 10 deletions
  1. 8 2
      crates/cdk/src/mint/mod.rs
  2. 6 1
      crates/cdk/src/pub_sub.rs
  3. 7 7
      misc/mintd_payment_processor.sh

+ 8 - 2
crates/cdk/src/mint/mod.rs

@@ -530,7 +530,9 @@ impl Mint {
         pubsub_manager: Arc<PubSubManager>,
         pubsub_manager: Arc<PubSubManager>,
         shutdown: Arc<Notify>,
         shutdown: Arc<Notify>,
     ) -> Result<(), Error> {
     ) -> Result<(), Error> {
+        let mut payment_id: usize = 0;
         loop {
         loop {
+            tracing::info!("Waiting for next paymentx");
             tokio::select! {
             tokio::select! {
                 _ = shutdown.notified() => {
                 _ = shutdown.notified() => {
                     processor.cancel_wait_invoice();
                     processor.cancel_wait_invoice();
@@ -540,6 +542,8 @@ impl Mint {
                     match result {
                     match result {
                         Ok(mut stream) => {
                         Ok(mut stream) => {
                             while let Some(event) = stream.next().await {
                             while let Some(event) = stream.next().await {
+                                payment_id += 1;
+                                tracing::info!("Got paymentx {}", payment_id);
                                 match event {
                                 match event {
                                     cdk_common::payment::Event::PaymentReceived(wait_payment_response) => {
                                     cdk_common::payment::Event::PaymentReceived(wait_payment_response) => {
                                         if let Err(e) = Self::handle_payment_notification(
                                         if let Err(e) = Self::handle_payment_notification(
@@ -547,20 +551,22 @@ impl Mint {
                                             &pubsub_manager,
                                             &pubsub_manager,
                                             wait_payment_response,
                                             wait_payment_response,
                                         ).await {
                                         ).await {
-                                            tracing::warn!("Payment notification error: {:?}", e);
+                                            tracing::warn!("Payment {} notification error: {:?}", payment_id, e);
                                         }
                                         }
                                     }
                                     }
                                 }
                                 }
+                                tracing::info!("Payment {}, Done processing paymentx", payment_id);
                             }
                             }
                         }
                         }
                         Err(e) => {
                         Err(e) => {
-                            tracing::warn!("Failed to get payment stream: {}", e);
+                            tracing::warn!("Payment {} Failed to get payment stream: {}", payment_id, e );
                             tokio::time::sleep(Duration::from_secs(5)).await;
                             tokio::time::sleep(Duration::from_secs(5)).await;
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
         }
         }
+
         Ok(())
         Ok(())
     }
     }
 
 

+ 6 - 1
crates/cdk/src/pub_sub.rs

@@ -150,7 +150,7 @@ where
         sub_id: SubId,
         sub_id: SubId,
         indexes: Vec<Index<I>>,
         indexes: Vec<Index<I>>,
     ) -> ActiveSubscription<T, I> {
     ) -> ActiveSubscription<T, I> {
-        let (sender, receiver) = mpsc::channel(10);
+        let (sender, receiver) = mpsc::channel(100);
 
 
         let mut index_storage = self.indexes.write().await;
         let mut index_storage = self.indexes.write().await;
         // Subscribe to events as soon as possible
         // Subscribe to events as soon as possible
@@ -175,6 +175,11 @@ where
                     .await
                     .await
                 {
                 {
                     Ok(events) => {
                     Ok(events) => {
+                        tracing::info!(
+                            "Subscription {:?} has matched {} events from the DB",
+                            sub_id_for_worker,
+                            events.len(),
+                        );
                         for event in events {
                         for event in events {
                             let _ = sender
                             let _ = sender
                                 .try_send((sub_id_for_worker.clone(), event.clone()))
                                 .try_send((sub_id_for_worker.clone(), event.clone()))

+ 7 - 7
misc/mintd_payment_processor.sh

@@ -22,7 +22,7 @@ cleanup() {
     # Remove the temporary directory
     # Remove the temporary directory
     rm -rf "$CDK_ITESTS_DIR"
     rm -rf "$CDK_ITESTS_DIR"
     echo "Temp directory removed: $CDK_ITESTS_DIR"
     echo "Temp directory removed: $CDK_ITESTS_DIR"
-    
+
     # Unset all environment variables that were set
     # Unset all environment variables that were set
     unset CDK_ITESTS_DIR
     unset CDK_ITESTS_DIR
     unset CDK_ITESTS_MINT_ADDR
     unset CDK_ITESTS_MINT_ADDR
@@ -74,7 +74,7 @@ fi
 echo "Temp directory created: $CDK_ITESTS_DIR"
 echo "Temp directory created: $CDK_ITESTS_DIR"
 export MINT_DATABASE="$1";
 export MINT_DATABASE="$1";
 
 
-cargo build -p cdk-integration-tests 
+cargo build -p cdk-integration-tests
 
 
 
 
 export CDK_TEST_REGTEST=0
 export CDK_TEST_REGTEST=0
@@ -125,7 +125,7 @@ echo "$CDK_PAYMENT_PROCESSOR_CLN_RPC_PATH"
 
 
 cargo b --bin cdk-payment-processor
 cargo b --bin cdk-payment-processor
 
 
-cargo run --bin cdk-payment-processor &
+cargo run --bin cdk-payment-processor -- --enable-logging --log-level=info &
 
 
 CDK_PAYMENT_PROCESSOR_PID=$!
 CDK_PAYMENT_PROCESSOR_PID=$!
 
 
@@ -140,10 +140,10 @@ export CDK_MINTD_GRPC_PAYMENT_PROCESSOR_PORT="8090";
 export CDK_MINTD_LOGGING_CONSOLE_LEVEL="debug"
 export CDK_MINTD_LOGGING_CONSOLE_LEVEL="debug"
 export CDK_MINTD_GRPC_PAYMENT_PROCESSOR_SUPPORTED_UNITS="sat";
 export CDK_MINTD_GRPC_PAYMENT_PROCESSOR_SUPPORTED_UNITS="sat";
 export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal";
 export CDK_MINTD_MNEMONIC="eye survey guilt napkin crystal cup whisper salt luggage manage unveil loyal";
- 
+
 cargo build --bin cdk-mintd --no-default-features --features grpc-processor
 cargo build --bin cdk-mintd --no-default-features --features grpc-processor
 
 
-cargo run --bin cdk-mintd --no-default-features --features grpc-processor &
+cargo run --bin cdk-mintd --no-default-features --features grpc-processor -- --enable-logging &
 CDK_MINTD_PID=$!
 CDK_MINTD_PID=$!
 
 
 echo $CDK_ITESTS_DIR
 echo $CDK_ITESTS_DIR
@@ -154,7 +154,7 @@ START_TIME=$(date +%s)
 while true; do
 while true; do
     # Get the current time
     # Get the current time
     CURRENT_TIME=$(date +%s)
     CURRENT_TIME=$(date +%s)
-    
+
     # Calculate the elapsed time
     # Calculate the elapsed time
     ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
     ELAPSED_TIME=$((CURRENT_TIME - START_TIME))
 
 
@@ -187,7 +187,7 @@ if [ "$LN_BACKEND" = "CLN" ]; then
     echo "Running bolt12 tests for CLN backend"
     echo "Running bolt12 tests for CLN backend"
     RUST_LOG=info cargo test -p cdk-integration-tests --test bolt12
     RUST_LOG=info cargo test -p cdk-integration-tests --test bolt12
     bolt12_test_status=$?
     bolt12_test_status=$?
-    
+
     # Exit with non-zero status if either test failed
     # Exit with non-zero status if either test failed
     if [ $test_status -ne 0 ] || [ $bolt12_test_status -ne 0 ]; then
     if [ $test_status -ne 0 ] || [ $bolt12_test_status -ne 0 ]; then
         echo "Tests failed - happy_path_mint_wallet: $test_status, bolt12: $bolt12_test_status"
         echo "Tests failed - happy_path_mint_wallet: $test_status, bolt12: $bolt12_test_status"