فهرست منبع

mmproxy/monero: Implement generateblocks RPC

parazyd 2 سال پیش
والد
کامیت
d8247cf0ca
2فایلهای تغییر یافته به همراه17 افزوده شده و 3 حذف شده
  1. 1 1
      bin/darkfi-mmproxy/src/main.rs
  2. 16 2
      bin/darkfi-mmproxy/src/monero.rs

+ 1 - 1
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,
             "getblocktemplate" => self.monero_get_block_template(req.id, req.params).await,
             "submit_block" => self.monero_submit_block(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,
             "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_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_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,
             "get_block_header_by_height" => self.monero_get_block_header_by_height(req.id, req.params).await,

+ 16 - 2
bin/darkfi-mmproxy/src/monero.rs

@@ -256,11 +256,25 @@ impl MiningProxy {
         JsonResponse::new(rep, id).into()
         JsonResponse::new(rep, id).into()
     }
     }
 
 
-    /*
+    /// Generate a block and specify the address to receive the coinbase reward.
+    /// <https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#generateblocks>
     pub async fn monero_generateblocks(&self, id: u16, params: JsonValue) -> JsonResult {
     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 {
     pub async fn monero_get_last_block_header(&self, id: u16, params: JsonValue) -> JsonResult {
         todo!()
         todo!()
     }
     }