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

This commit is contained in:
skoupidi
2025-12-29 16:23:23 +02:00
parent 86f6e8712b
commit 16151cc4b0
2 changed files with 18 additions and 9 deletions

View File

@@ -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()

View File

@@ -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