Explorar o código

mmproxy: Duck hunting

parazyd %!s(int64=2) %!d(string=hai) anos
pai
achega
fdb84606ca
Modificáronse 2 ficheiros con 4 adicións e 3 borrados
  1. 1 2
      bin/darkfi-mmproxy/src/main.rs
  2. 3 1
      bin/darkfi-mmproxy/src/stratum.rs

+ 1 - 2
bin/darkfi-mmproxy/src/main.rs

@@ -153,7 +153,6 @@ async fn realmain(args: Args, ex: Arc<Executor<'static>>) -> Result<()> {
     info!("Starting DarkFi x Monero merge mining proxy...");
 
     let mmproxy = Arc::new(MiningProxy::new(args.monerod, ex.clone()).await?);
-    let mmproxy_ = Arc::clone(&mmproxy);
 
     info!("Starting JSON-RPC server");
     let rpc_task = StoppableTask::new();
@@ -161,7 +160,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'static>>) -> Result<()> {
         listen_and_serve(args.rpc_listen, mmproxy.clone(), None, ex.clone()),
         |res| async move {
             match res {
-                Ok(()) | Err(Error::RpcServerStopped) => mmproxy_.stop_connections().await,
+                Ok(()) | Err(Error::RpcServerStopped) => mmproxy.stop_connections().await,
                 Err(e) => error!("Failed stopping JSON-RPC server: {}", e),
             }
         },

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

@@ -347,6 +347,8 @@ impl MiningProxy {
 
             // In case it's the same job, we'll wait and try again
             if worker.mining_job.job_id == mining_job.job_id {
+                // Drop the workers lock before sleeping.
+                drop(workers_ptr);
                 match timeout(POLL_INTERVAL, submit_recv.recv()).await {
                     Ok(_) => continue,
                     Err(_) => continue,
@@ -366,7 +368,7 @@ impl MiningProxy {
                 break
             }
 
-            debug!(target: "stratum::job_task", "Dropped workers write lock");
+            // Drop the workers lock before sleeping.
             drop(workers_ptr);
 
             // Now poll or wait for a trigger for a new job.