|
|
@@ -1,3 +1,21 @@
|
|
|
+/* This file is part of DarkFi (https://dark.fi)
|
|
|
+ *
|
|
|
+ * Copyright (C) 2020-2023 Dyne.org foundation
|
|
|
+ *
|
|
|
+ * This program is free software: you can redistribute it and/or modify
|
|
|
+ * it under the terms of the GNU Affero General Public License as
|
|
|
+ * published by the Free Software Foundation, either version 3 of the
|
|
|
+ * License, or (at your option) any later version.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ * GNU Affero General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU Affero General Public License
|
|
|
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
+ */
|
|
|
+
|
|
|
use std::{collections::HashSet, sync::Arc};
|
|
|
|
|
|
use darkfi::{
|
|
|
@@ -21,6 +39,7 @@ use structopt::StructOpt;
|
|
|
use structopt_toml::StructOptToml;
|
|
|
use url::Url;
|
|
|
|
|
|
+mod monero;
|
|
|
mod stratum;
|
|
|
|
|
|
const CONFIG_FILE: &str = "darkfi_mmproxy.toml";
|
|
|
@@ -59,12 +78,53 @@ impl MiningProxy {
|
|
|
}
|
|
|
|
|
|
#[async_trait]
|
|
|
+#[rustfmt::skip]
|
|
|
impl RequestHandler for MiningProxy {
|
|
|
async fn handle_request(&self, req: JsonRequest) -> JsonResult {
|
|
|
error!(target: "mmproxy::rpc", "--> {}", req.stringify().unwrap());
|
|
|
|
|
|
match req.method.as_str() {
|
|
|
"ping" => self.pong(req.id, req.params).await,
|
|
|
+
|
|
|
+ // Stratum methods
|
|
|
+ "login" => self.stratum_login(req.id, req.params).await,
|
|
|
+ "job" => self.stratum_job(req.id, req.params).await,
|
|
|
+ "submit" => self.stratum_submit(req.id, req.params).await,
|
|
|
+ "keepalived" => self.stratum_keepalived(req.id, req.params).await,
|
|
|
+
|
|
|
+ // Monero daemon methods
|
|
|
+ "get_block_count" => self.monero_get_block_count(req.id, req.params).await,
|
|
|
+ "on_get_block_hash" => self.monero_on_get_block_hash(req.id, req.params).await,
|
|
|
+ "get_block_template" => self.monero_get_block_template(req.id, req.params).await,
|
|
|
+ "submit_block" => self.monero_submit_block(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,
|
|
|
+ "get_block_headers_range" => self.monero_get_block_headers_range(req.id, req.params).await,
|
|
|
+ "get_block" => self.monero_get_block(req.id, req.params).await,
|
|
|
+ "get_connections" => self.monero_get_connections(req.id, req.params).await,
|
|
|
+ "get_info" => self.monero_get_info(req.id, req.params).await,
|
|
|
+ "hard_fork_info" => self.monero_hard_fork_info(req.id, req.params).await,
|
|
|
+ "set_bans" => self.monero_set_bans(req.id, req.params).await,
|
|
|
+ "get_bans" => self.monero_get_bans(req.id, req.params).await,
|
|
|
+ "banned" => self.monero_banned(req.id, req.params).await,
|
|
|
+ "flush_txpool" => self.monero_flush_txpool(req.id, req.params).await,
|
|
|
+ "get_output_histogram" => self.monero_get_output_histogram(req.id, req.params).await,
|
|
|
+ "get_version" => self.monero_get_version(req.id, req.params).await,
|
|
|
+ "get_coinbase_tx_sum" => self.monero_get_coinbase_tx_sum(req.id, req.params).await,
|
|
|
+ "get_fee_estimate" => self.monero_get_fee_estimate(req.id, req.params).await,
|
|
|
+ "get_alternate_chains" => self.monero_get_alternate_chains(req.id, req.params).await,
|
|
|
+ "relay_tx" => self.monero_relay_tx(req.id, req.params).await,
|
|
|
+ "sync_info" => self.monero_sync_info(req.id, req.params).await,
|
|
|
+ "get_txpool_backlog" => self.monero_get_txpool_backlog(req.id, req.params).await,
|
|
|
+ "get_output_distribution" => self.monero_get_output_distribution(req.id, req.params).await,
|
|
|
+ "get_miner_data" => self.monero_get_miner_data(req.id, req.params).await,
|
|
|
+ "prune_blockchain" => self.monero_prune_blockchain(req.id, req.params).await,
|
|
|
+ "calc_pow" => self.monero_calc_pow(req.id, req.params).await,
|
|
|
+ "flush_cache" => self.monero_flush_cache(req.id, req.params).await,
|
|
|
+ "add_aux_pow" => self.monero_add_aux_pow(req.id, req.params).await,
|
|
|
+
|
|
|
_ => JsonError::new(ErrorCode::MethodNotFound, None, req.id).into(),
|
|
|
}
|
|
|
}
|