From d8247cf0ca5fe0efe07ed21068821e11587ea857 Mon Sep 17 00:00:00 2001 From: parazyd Date: Wed, 8 Nov 2023 11:21:27 +0100 Subject: [PATCH] mmproxy/monero: Implement generateblocks RPC --- bin/darkfi-mmproxy/src/main.rs | 2 +- bin/darkfi-mmproxy/src/monero.rs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/darkfi-mmproxy/src/main.rs b/bin/darkfi-mmproxy/src/main.rs index a63ec8fcbd65..6a7f818542aa 100644 --- a/bin/darkfi-mmproxy/src/main.rs +++ b/bin/darkfi-mmproxy/src/main.rs @@ -171,9 +171,9 @@ impl RequestHandler for MiningProxy { "getblocktemplate" => self.monero_get_block_template(req.id, req.params).await, "submit_block" => self.monero_submit_block(req.id, req.params).await, "submitblock" => self.monero_submit_block(req.id, req.params).await, + "generateblocks" => self.monero_generateblocks(req.id, req.params).await, /* - "generateblocks" => self.monero_generateblocks(req.id, req.params).await, "get_last_block_header" => self.monero_get_last_block_header(req.id, req.params).await, "get_block_header_by_hash" => self.monero_get_block_header_by_hash(req.id, req.params).await, "get_block_header_by_height" => self.monero_get_block_header_by_height(req.id, req.params).await, diff --git a/bin/darkfi-mmproxy/src/monero.rs b/bin/darkfi-mmproxy/src/monero.rs index 90c08652e745..0215efc5cb17 100644 --- a/bin/darkfi-mmproxy/src/monero.rs +++ b/bin/darkfi-mmproxy/src/monero.rs @@ -256,11 +256,25 @@ impl MiningProxy { JsonResponse::new(rep, id).into() } - /* + /// Generate a block and specify the address to receive the coinbase reward. + /// pub async fn monero_generateblocks(&self, id: u16, params: JsonValue) -> JsonResult { - todo!() + debug!(target: "rpc::monero", "generateblocks()"); + + // This request can just passthrough + let req = JsonRequest::new("generateblocks", params); + let rep = match self.oneshot_request(req).await { + Ok(v) => v, + Err(e) => { + error!(target: "rpc::monero::generateblocks", "[RPC] {}", e); + return JsonError::new(InternalError, Some(e.to_string()), id).into() + } + }; + + JsonResponse::new(rep, id).into() } + /* pub async fn monero_get_last_block_header(&self, id: u16, params: JsonValue) -> JsonResult { todo!() }