Bladeren bron

darkfid/rpc: don't return error when node is out of sync so xmrig/p2pool don't dc

skoupidi 7 maanden geleden
bovenliggende
commit
16151cc4b0
2 gewijzigde bestanden met toevoegingen van 18 en 9 verwijderingen
  1. 9 7
      bin/darkfid/src/rpc/rpc_stratum.rs
  2. 9 2
      bin/darkfid/src/rpc/rpc_xmr.rs

+ 9 - 7
bin/darkfid/src/rpc/rpc_stratum.rs

@@ -93,7 +93,7 @@ impl DarkfiNode {
     pub async fn stratum_login(&self, id: u16, params: JsonValue) -> JsonResult {
         // Check if node is synced before responding
         if !*self.validator.synced.read().await {
-            return server_error(RpcError::NotSynced, id, None)
+            return JsonResponse::new(JsonValue::from(HashMap::new()), id).into()
         }
 
         // Parse request params
@@ -201,7 +201,14 @@ impl DarkfiNode {
     pub async fn stratum_submit(&self, id: u16, params: JsonValue) -> JsonResult {
         // Check if node is synced before responding
         if !*self.validator.synced.read().await {
-            return server_error(RpcError::NotSynced, id, None)
+            return JsonResponse::new(
+                JsonValue::from(HashMap::from([(
+                    "status".to_string(),
+                    JsonValue::from(String::from("rejected")),
+                )])),
+                id,
+            )
+            .into()
         }
 
         // Grab registry submissions lock
@@ -361,11 +368,6 @@ impl DarkfiNode {
     // --> {"jsonrpc":"2.0", "method": "keepalived", "id": 1, "params": {"id": "foo"}}
     // <-- {"jsonrpc":"2.0", "id": 1, "result": {"status": "KEEPALIVED"}}
     pub async fn stratum_keepalived(&self, id: u16, params: JsonValue) -> JsonResult {
-        // Check if node is synced before responding
-        if !*self.validator.synced.read().await {
-            return server_error(RpcError::NotSynced, id, None)
-        }
-
         // Parse request params
         let Some(params) = params.get::<HashMap<String, JsonValue>>() else {
             return JsonError::new(InvalidParams, None, id).into()

+ 9 - 2
bin/darkfid/src/rpc/rpc_xmr.rs

@@ -143,7 +143,7 @@ impl DarkfiNode {
     pub async fn xmr_merge_mining_get_aux_block(&self, id: u16, params: JsonValue) -> JsonResult {
         // Check if node is synced before responding to p2pool
         if !*self.validator.synced.read().await {
-            return server_error(RpcError::NotSynced, id, None)
+            return JsonResponse::new(JsonValue::from(HashMap::new()), id).into()
         }
 
         // Parse request params
@@ -252,7 +252,14 @@ impl DarkfiNode {
     pub async fn xmr_merge_mining_submit_solution(&self, id: u16, params: JsonValue) -> JsonResult {
         // Check if node is synced before responding to p2pool
         if !*self.validator.synced.read().await {
-            return server_error(RpcError::NotSynced, id, None)
+            return JsonResponse::new(
+                JsonValue::from(HashMap::from([(
+                    "status".to_string(),
+                    JsonValue::from(String::from("rejected")),
+                )])),
+                id,
+            )
+            .into()
         }
 
         // Grab registry submissions lock