Jelajahi Sumber

mmproxy/stratum: Add more debug messages

parazyd 2 tahun lalu
induk
melakukan
19c0e7af4d
1 mengubah file dengan 17 tambahan dan 3 penghapusan
  1. 17 3
      bin/darkfi-mmproxy/src/stratum.rs

+ 17 - 3
bin/darkfi-mmproxy/src/stratum.rs

@@ -26,7 +26,7 @@ use darkfi::{
     system::{timeout::timeout, StoppableTask},
     system::{timeout::timeout, StoppableTask},
     Error, Result,
     Error, Result,
 };
 };
-use log::{debug, error, warn};
+use log::{debug, error, info, warn};
 use smol::{channel, lock::RwLock};
 use smol::{channel, lock::RwLock};
 use uuid::Uuid;
 use uuid::Uuid;
 
 
@@ -43,6 +43,7 @@ impl MiningProxy {
         uuid: Uuid,
         uuid: Uuid,
         ka_recv: channel::Receiver<()>,
         ka_recv: channel::Receiver<()>,
     ) -> Result<()> {
     ) -> Result<()> {
+        debug!("Spawned keepalive_task for worker {}", uuid);
         const TIMEOUT: Duration = Duration::from_secs(60);
         const TIMEOUT: Duration = Duration::from_secs(60);
 
 
         loop {
         loop {
@@ -54,7 +55,10 @@ impl MiningProxy {
             };
             };
 
 
             match r {
             match r {
-                Ok(()) => continue,
+                Ok(()) => {
+                    debug!("keepalive_task {} got ping", uuid);
+                    continue
+                }
                 Err(e) => {
                 Err(e) => {
                     error!("keepalive_task {} channel recv error: {}", uuid, e);
                     error!("keepalive_task {} channel recv error: {}", uuid, e);
                     workers.write().await.remove(&uuid);
                     workers.write().await.remove(&uuid);
@@ -168,7 +172,17 @@ impl MiningProxy {
             self.executor.clone(),
             self.executor.clone(),
         );
         );
 
 
-        todo!("send current job")
+        info!("Added worker {} ({})", login, uuid);
+
+        // TODO: Send current job
+        return JsonResponse::new(
+            JsonValue::Object(HashMap::from([(
+                "status".to_string(),
+                JsonValue::String("KEEPALIVED".to_string()),
+            )])),
+            id,
+        )
+        .into()
     }
     }
 
 
     pub async fn stratum_submit(&self, id: u16, params: JsonValue) -> JsonResult {
     pub async fn stratum_submit(&self, id: u16, params: JsonValue) -> JsonResult {