darkfid: split managemtn rpc methods into its own rpc server and standarized all ports

This commit is contained in:
skoupidi
2026-01-02 19:41:20 +02:00
parent 4f30aae91d
commit fcf4aded0e
37 changed files with 359 additions and 215 deletions

View File

@@ -9,6 +9,9 @@
# Blockchain network to use
network = "testnet"
## =====================
## TESTNET CONFIGURATION
## =====================
# Testnet blockchain network configuration
[network_config."testnet"]
# Path to the blockchain database directory
@@ -38,15 +41,23 @@ txs_batch_size = 50
## Testnet JSON-RPC settings
[network_config."testnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:8340"
rpc_listen = "tcp://127.0.0.1:18345"
# Disabled RPC methods
rpc_disabled_methods = ["p2p.get_info"]
#rpc_disabled_methods = []
## Testnet management JSON-RPC settings
[network_config."testnet".management_rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:18346"
# Disabled RPC methods
#rpc_disabled_methods = []
## Testnet JSON-RPC settings for stratum mining requests (optional)
#[network_config."testnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
#rpc_listen = "tcp://127.0.0.1:8341"
#rpc_listen = "tcp://127.0.0.1:18347"
# Disabled RPC methods (stratum mining)
#rpc_disabled_methods = []
@@ -54,7 +65,7 @@ rpc_disabled_methods = ["p2p.get_info"]
## Testnet JSON-RPC settings for p2pool merge mining requests (optional)
#[network_config."testnet".mm_rpc]
# JSON-RPC listen URL (merge mining)
#rpc_listen = "http+tcp://127.0.0.1:8341"
#rpc_listen = "http+tcp://127.0.0.1:18348"
# Disabled RPC methods (merge mining)
#rpc_disabled_methods = []
@@ -109,41 +120,41 @@ active_profiles = ["tor"]
[network_config."testnet".net.profiles."tcp+tls"]
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = ["tcp+tls://lilith0.dark.fi:8342", "tcp+tls://lilith1.dark.fi:8342"]
seeds = ["tcp+tls://lilith0.dark.fi:18340", "tcp+tls://lilith1.dark.fi:18340"]
# Peer nodes to manually connect to
#peers = []
# P2P accept addresses the instance listens on for inbound connections
# You can also use an IPv6 address
#inbound = ["tcp+tls://0.0.0.0:8342"]
#inbound = ["tcp+tls://0.0.0.0:18340"]
# IPv6 version:
#inbound = ["tcp+tls://[::]:8342"]
#inbound = ["tcp+tls://[::]:18340"]
# Combined:
#inbound = ["tcp+tls://0.0.0.0:8342", "tcp+tls://[::]:8342"]
#inbound = ["tcp+tls://0.0.0.0:18340", "tcp+tls://[::]:18340"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
# You can also use an IPv6 address
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8342"]
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:18340"]
# IPv6 version:
#external_addrs = ["tcp+tls://[ipv6 address here]:8342"]
#external_addrs = ["tcp+tls://[ipv6 address here]:18340"]
# Combined:
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8342", "tcp+tls://[ipv6 address here]:8342"]
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:18340", "tcp+tls://[ipv6 address here]:18340"]
[network_config."testnet".net.profiles."tor"]
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = [
"tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:8343",
"tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:8343",
"tor://g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:18341",
"tor://yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:18341",
]
# Peer nodes to manually connect to
#peers = []
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tor://127.0.0.1:8342"]
#inbound = ["tor://127.0.0.1:18341"]
[network_config."testnet".net.profiles."i2p"]
# Seed nodes to connect to for peer discovery and/or adversising our
@@ -154,18 +165,18 @@ seeds = [
#peers = []
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tcp://127.0.0.1:25551"]
#inbound = ["tcp://127.0.0.1:18342"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
#external_addrs = ["i2p://youraddress.b32.i2p:25551"]
#external_addrs = ["i2p://youraddress.b32.i2p:18342"]
[network_config."testnet".net.profiles."socks5"]
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = [
"socks5://127.0.0.1:9050/g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:8343",
"socks5://127.0.0.1:9050/yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:8343",
"socks5://127.0.0.1:9050/g7fxelebievvpr27w7gt24lflptpw3jeeuvafovgliq5utdst6xyruyd.onion:18341",
"socks5://127.0.0.1:9050/yvklzjnfmwxhyodhrkpomawjcdvcaushsj6torjz2gyd7e25f3gfunyd.onion:18341",
]
# Peer nodes to manually connect to
@@ -175,8 +186,8 @@ seeds = [
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = [
#"socks5+tls://127.0.0.1:9050/lilith0.dark.fi:8342",
#"socks5+tls://127.0.0.1:1080/lilith1.dark.fi:8342"
#"socks5+tls://127.0.0.1:9050/lilith0.dark.fi:18340",
#"socks5+tls://127.0.0.1:1080/lilith1.dark.fi:18340"
]
# Peer nodes to manually connect to
@@ -186,13 +197,16 @@ seeds = [
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = [
"tor+tls://lilith0.dark.fi:8342",
"tor+tls://lilith1.dark.fi:8342"
"tor+tls://lilith0.dark.fi:18340",
"tor+tls://lilith1.dark.fi:18340"
]
# Peer nodes to manually connect to
#peers = []
## =====================
## MAINNET CONFIGURATION
## =====================
# Mainnet blockchain network configuration
[network_config."mainnet"]
# Path to the blockchain database directory
@@ -222,15 +236,23 @@ txs_batch_size = 50
## Mainnet JSON-RPC settings
[network_config."mainnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:8440"
rpc_listen = "tcp://127.0.0.1:8345"
# Disabled RPC methods
rpc_disabled_methods = ["p2p.get_info"]
#rpc_disabled_methods = []
## Mainnet management JSON-RPC settings
[network_config."mainnet".management_rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:8346"
# Disabled RPC methods
#rpc_disabled_methods = []
## Mainnet JSON-RPC settings for stratum mining requests (optional)
#[network_config."mainnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
#rpc_listen = "tcp://127.0.0.1:8441"
#rpc_listen = "tcp://127.0.0.1:8347"
# Disabled RPC methods (stratum mining)
#rpc_disabled_methods = []
@@ -238,7 +260,7 @@ rpc_disabled_methods = ["p2p.get_info"]
## Mainnet JSON-RPC settings for p2pool merge mining requests (optional)
#[network_config."mainnet".mm_rpc]
# JSON-RPC listen URL (merge mining)
#rpc_listen = "http+tcp://127.0.0.1:8441"
#rpc_listen = "http+tcp://127.0.0.1:8348"
# Disabled RPC methods (merge mining)
#rpc_disabled_methods = []
@@ -299,27 +321,27 @@ active_profiles = ["tor"]
[network_config."mainnet".net.profiles."tcp+tls"]
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"]
seeds = ["tcp+tls://lilith0.dark.fi:8340", "tcp+tls://lilith1.dark.fi:8340"]
# Peer nodes to manually connect to
#peers = []
# P2P accept addresses the instance listens on for inbound connections
# You can also use an IPv6 address
#inbound = ["tcp+tls://0.0.0.0:8442"]
#inbound = ["tcp+tls://0.0.0.0:8340"]
# IPv6 version:
#inbound = ["tcp+tls://[::]:8442"]
#inbound = ["tcp+tls://[::]:8340"]
# Combined:
#inbound = ["tcp+tls://0.0.0.0:8442", "tcp+tls://[::]:8442"]
#inbound = ["tcp+tls://0.0.0.0:8340", "tcp+tls://[::]:8340"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
# You can also use an IPv6 address
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8442"]
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8340"]
# IPv6 version:
#external_addrs = ["tcp+tls://[ipv6 address here]:8442"]
#external_addrs = ["tcp+tls://[ipv6 address here]:8340"]
# Combined:
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8442", "tcp+tls://[ipv6 address here]:8442"]
#external_addrs = ["tcp+tls://XXX.XXX.XXX.XXX:8340", "tcp+tls://[ipv6 address here]:8340"]
[network_config."mainnet".net.profiles."tor"]
# Seed nodes to connect to for peer discovery and/or adversising our
@@ -330,7 +352,7 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"]
#peers = []
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tor://127.0.0.1:8442"]
#inbound = ["tor://127.0.0.1:8341"]
[network_config."mainnet".net.profiles."i2p"]
# Seed nodes to connect to for peer discovery and/or adversising our
@@ -341,11 +363,11 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"]
#peers = []
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tcp://127.0.0.1:8442"]
#inbound = ["tcp://127.0.0.1:8342"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
#external_addrs = ["i2p://youraddress.b32.i2p:8442"]
#external_addrs = ["i2p://youraddress.b32.i2p:8342"]
[network_config."mainnet".net.profiles."socks5"]
# Seed nodes to connect to for peer discovery and/or adversising our
@@ -371,8 +393,9 @@ seeds = ["tcp+tls://lilith0.dark.fi:8442", "tcp+tls://lilith1.dark.fi:8442"]
# Peer nodes to manually connect to
#peers = []
## ======================
## LOCALNET CONFIGURATION
## ======================
# Localnet blockchain network configuration
[network_config."localnet"]
# Path to the blockchain database directory
@@ -405,15 +428,23 @@ txs_batch_size = 50
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:8240"
rpc_listen = "tcp://127.0.0.1:28345"
# Disabled RPC methods
rpc_disabled_methods = ["p2p.get_info"]
#rpc_disabled_methods = []
## Localnet management JSON-RPC settings
[network_config."localnet".management_rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:28346"
# Disabled RPC methods
#rpc_disabled_methods = []
## Localnet JSON-RPC settings for stratum mining requests (optional)
#[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
#rpc_listen = "tcp://127.0.0.1:8241"
#rpc_listen = "tcp://127.0.0.1:28347"
# Disabled RPC methods (stratum mining)
#rpc_disabled_methods = []
@@ -421,7 +452,7 @@ rpc_disabled_methods = ["p2p.get_info"]
## Localnet JSON-RPC settings for p2pool merge mining requests (optional)
#[network_config."localnet".mm_rpc]
# JSON-RPC listen URL (merge mining)
#rpc_listen = "http+tcp://127.0.0.1:8241"
#rpc_listen = "http+tcp://127.0.0.1:28348"
# Disabled RPC methods (merge mining)
#rpc_disabled_methods = []
@@ -481,7 +512,7 @@ localnet = true
[net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tcp+tls://0.0.0.0:8242"]
#inbound = ["tcp+tls://0.0.0.0:28340"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
@@ -496,7 +527,7 @@ localnet = true
[net.profiles."tcp"]
# P2P accept addresses the instance listens on for inbound connections
#inbound = ["tcp://0.0.0.0:8242"]
#inbound = ["tcp://0.0.0.0:28340"]
# P2P external addresses the instance advertises so other peers can
# reach us and connect to us, as long as inbound addrs are configured.
@@ -507,4 +538,4 @@ localnet = true
# Seed nodes to connect to for peer discovery and/or adversising our
# own external addresses
#seeds = []
#seeds = []

View File

@@ -45,7 +45,7 @@ use error::{server_error, RpcError};
/// JSON-RPC requests handler and methods
mod rpc;
use rpc::DefaultRpcHandler;
use rpc::{management::ManagementRpcHandler, DefaultRpcHandler};
/// Validator async tasks
pub mod task;
@@ -76,6 +76,8 @@ pub struct DarkfiNode {
subscribers: HashMap<&'static str, JsonSubscriber>,
/// Main JSON-RPC connection tracker
rpc_connections: Mutex<HashSet<StoppableTaskPtr>>,
/// Management JSON-RPC connection tracker
management_rpc_connections: Mutex<HashSet<StoppableTaskPtr>>,
}
impl DarkfiNode {
@@ -93,6 +95,7 @@ impl DarkfiNode {
txs_batch_size,
subscribers,
rpc_connections: Mutex::new(HashSet::new()),
management_rpc_connections: Mutex::new(HashSet::new()),
}))
}
}
@@ -108,6 +111,8 @@ pub struct Darkfid {
dnet_task: StoppableTaskPtr,
/// Main JSON-RPC background task
rpc_task: StoppableTaskPtr,
/// Management JSON-RPC background task
management_rpc_task: StoppableTaskPtr,
/// Consensus protocol background task
consensus_task: StoppableTaskPtr,
}
@@ -161,19 +166,22 @@ impl Darkfid {
// Generate the background tasks
let dnet_task = StoppableTask::new();
let rpc_task = StoppableTask::new();
let management_rpc_task = StoppableTask::new();
let consensus_task = StoppableTask::new();
info!(target: "darkfid::Darkfid::init", "Darkfi daemon initialized successfully!");
Ok(Arc::new(Self { node, dnet_task, rpc_task, consensus_task }))
Ok(Arc::new(Self { node, dnet_task, rpc_task, management_rpc_task, consensus_task }))
}
/// Start the DarkFi daemon in the given executor, using the provided JSON-RPC listen url
/// and consensus initialization configuration.
/// Start the DarkFi daemon in the given executor, using the
/// provided JSON-RPC settings and consensus initialization
/// configuration.
pub async fn start(
&self,
executor: &ExecutorPtr,
rpc_settings: &RpcSettings,
management_rpc_settings: &RpcSettings,
stratum_rpc_settings: &Option<RpcSettings>,
mm_rpc_settings: &Option<RpcSettings>,
config: &ConsensusInitTaskConfig,
@@ -218,6 +226,21 @@ impl Darkfid {
executor.clone(),
);
// Start the management JSON-RPC task
info!(target: "darkfid::Darkfid::start", "Starting management JSON-RPC server");
let node_ = self.node.clone();
self.management_rpc_task.clone().start(
listen_and_serve::<ManagementRpcHandler>(management_rpc_settings.clone(), self.node.clone(), None, executor.clone()),
|res| async move {
match res {
Ok(()) | Err(Error::RpcServerStopped) => <DarkfiNode as RequestHandler<ManagementRpcHandler>>::stop_connections(&node_).await,
Err(e) => error!(target: "darkfid::Darkfid::start", "Failed starting management JSON-RPC server: {e}"),
}
},
Error::RpcServerStopped,
executor.clone(),
);
// Start the miners registry
info!(target: "darkfid::Darkfid::start", "Starting miners registry");
self.node.registry.start(executor, &self.node, stratum_rpc_settings, mm_rpc_settings)?;
@@ -260,6 +283,10 @@ impl Darkfid {
info!(target: "darkfid::Darkfid::stop", "Stopping main JSON-RPC server...");
self.rpc_task.stop().await;
// Stop the management JSON-RPC task
info!(target: "darkfid::Darkfid::stop", "Stopping management JSON-RPC server...");
self.management_rpc_task.stop().await;
// Stop the miners registry
info!(target: "darkfid::Darkfid::stop", "Stopping miners registry...");
self.node.registry.stop().await;

View File

@@ -135,6 +135,10 @@ pub struct BlockchainNetwork {
/// Main server JSON-RPC settings
rpc: RpcSettingsOpt,
#[structopt(flatten)]
/// Management server JSON-RPC settings
management_rpc: RpcSettingsOpt,
#[structopt(skip)]
/// Stratum server JSON-RPC settings (optional)
stratum_rpc: Option<RpcSettingsOpt>,
@@ -251,6 +255,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
.start(
&ex,
&blockchain_config.rpc.into(),
&blockchain_config.management_rpc.into(),
&blockchain_config.stratum_rpc.map(|stratum_rpc_opts| stratum_rpc_opts.into()),
&blockchain_config.mm_rpc.map(|mm_rpc_opts| mm_rpc_opts.into()),
&config,

View File

@@ -0,0 +1,131 @@
/* This file is part of DarkFi (https://dark.fi)
*
* Copyright (C) 2020-2026 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;
use async_trait::async_trait;
use smol::lock::MutexGuard;
use tinyjson::JsonValue;
use tracing::debug;
use darkfi::{
net::P2pPtr,
rpc::{
jsonrpc::{ErrorCode, JsonError, JsonRequest, JsonResponse, JsonResult},
p2p_method::HandlerP2p,
server::RequestHandler,
},
system::StoppableTaskPtr,
};
use crate::DarkfiNode;
/// JSON-RPC `RequestHandler` for node management
pub struct ManagementRpcHandler;
#[async_trait]
#[rustfmt::skip]
impl RequestHandler<ManagementRpcHandler> for DarkfiNode {
async fn handle_request(&self, req: JsonRequest) -> JsonResult {
debug!(target: "darkfid::rpc::management_rpc", "--> {}", req.stringify().unwrap());
match req.method.as_str() {
// =======================
// Node management methods
// =======================
"ping" => <DarkfiNode as RequestHandler<ManagementRpcHandler>>::pong(self, req.id, req.params).await,
"dnet.switch" => self.dnet_switch(req.id, req.params).await,
"dnet.subscribe_events" => self.dnet_subscribe_events(req.id, req.params).await,
"p2p.get_info" => self.p2p_get_info(req.id, req.params).await,
_ => JsonError::new(ErrorCode::MethodNotFound, None, req.id).into(),
}
}
async fn connections_mut(&self) -> MutexGuard<'life0, HashSet<StoppableTaskPtr>> {
self.management_rpc_connections.lock().await
}
}
impl HandlerP2p for DarkfiNode {
fn p2p(&self) -> P2pPtr {
self.p2p_handler.p2p.clone()
}
}
impl DarkfiNode {
// RPCAPI:
// Activate or deactivate dnet in the P2P stack.
// By sending `true`, dnet will be activated, and by sending `false` dnet
// will be deactivated.
//
// Returns `true` on success.
//
// --> {"jsonrpc": "2.0", "method": "dnet.switch", "params": [true], "id": 1}
// <-- {"jsonrpc": "2.0", "result": true, "id": 1}
pub async fn dnet_switch(&self, id: u16, params: JsonValue) -> JsonResult {
let Some(params) = params.get::<Vec<JsonValue>>() else {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
};
if params.len() != 1 || !params[0].is_bool() {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
}
let switch = params[0].get::<bool>().unwrap();
if *switch {
self.p2p_handler.p2p.dnet_enable();
} else {
self.p2p_handler.p2p.dnet_disable();
}
JsonResponse::new(JsonValue::Boolean(true), id).into()
}
// RPCAPI:
// Initializes a subscription to P2P dnet events.
// Once a subscription is established, `darkfid` will send JSON-RPC
// notifications of new network events to the subscriber.
//
// --> {
// "jsonrpc": "2.0",
// "method": "dnet.subscribe_events",
// "params": [],
// "id": 1
// }
// <-- {
// "jsonrpc": "2.0",
// "method": "dnet.subscribe_events",
// "params": [
// {
// "chan": {"Channel": "Info"},
// "cmd": "command",
// "time": 1767016282
// }
// ]
// }
pub async fn dnet_subscribe_events(&self, id: u16, params: JsonValue) -> JsonResult {
let Some(params) = params.get::<Vec<JsonValue>>() else {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
};
if !params.is_empty() {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
}
self.subscribers.get("dnet").unwrap().clone().into()
}
}

View File

@@ -19,7 +19,7 @@
use tinyjson::JsonValue;
use darkfi::{
rpc::jsonrpc::{ErrorCode, JsonError, JsonResponse, JsonResult},
rpc::jsonrpc::{JsonResponse, JsonResult},
util::time::Timestamp,
};
@@ -34,65 +34,4 @@ impl DarkfiNode {
pub async fn clock(&self, id: u16, _params: JsonValue) -> JsonResult {
JsonResponse::new((Timestamp::current_time().inner() as f64).into(), id).into()
}
// RPCAPI:
// Activate or deactivate dnet in the P2P stack.
// By sending `true`, dnet will be activated, and by sending `false` dnet
// will be deactivated.
//
// Returns `true` on success.
//
// --> {"jsonrpc": "2.0", "method": "dnet.switch", "params": [true], "id": 1}
// <-- {"jsonrpc": "2.0", "result": true, "id": 1}
pub async fn dnet_switch(&self, id: u16, params: JsonValue) -> JsonResult {
let Some(params) = params.get::<Vec<JsonValue>>() else {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
};
if params.len() != 1 || !params[0].is_bool() {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
}
let switch = params[0].get::<bool>().unwrap();
if *switch {
self.p2p_handler.p2p.dnet_enable();
} else {
self.p2p_handler.p2p.dnet_disable();
}
JsonResponse::new(JsonValue::Boolean(true), id).into()
}
// RPCAPI:
// Initializes a subscription to P2P dnet events.
// Once a subscription is established, `darkfid` will send JSON-RPC
// notifications of new network events to the subscriber.
//
// --> {
// "jsonrpc": "2.0",
// "method": "dnet.subscribe_events",
// "params": [],
// "id": 1
// }
// <-- {
// "jsonrpc": "2.0",
// "method": "dnet.subscribe_events",
// "params": [
// {
// "chan": {"Channel": "Info"},
// "cmd": "command",
// "time": 1767016282
// }
// ]
// }
pub async fn dnet_subscribe_events(&self, id: u16, params: JsonValue) -> JsonResult {
let Some(params) = params.get::<Vec<JsonValue>>() else {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
};
if !params.is_empty() {
return JsonError::new(ErrorCode::InvalidParams, None, id).into()
}
self.subscribers.get("dnet").unwrap().clone().into()
}
}

View File

@@ -23,10 +23,8 @@ use smol::lock::MutexGuard;
use tracing::debug;
use darkfi::{
net::P2pPtr,
rpc::{
jsonrpc::{ErrorCode, JsonError, JsonRequest, JsonResult},
p2p_method::HandlerP2p,
server::RequestHandler,
},
system::StoppableTaskPtr,
@@ -49,6 +47,9 @@ pub mod xmr;
/// Misc JSON-RPC methods
pub mod misc;
/// Node management JSON-RPC methods
pub mod management;
/// Default JSON-RPC `RequestHandler`
pub struct DefaultRpcHandler;
@@ -64,9 +65,6 @@ impl RequestHandler<DefaultRpcHandler> for DarkfiNode {
// =====================
"ping" => <DarkfiNode as RequestHandler<DefaultRpcHandler>>::pong(self, req.id, req.params).await,
"clock" => self.clock(req.id, req.params).await,
"dnet.switch" => self.dnet_switch(req.id, req.params).await,
"dnet.subscribe_events" => self.dnet_subscribe_events(req.id, req.params).await,
"p2p.get_info" => self.p2p_get_info(req.id, req.params).await,
// ==================
// Blockchain methods
@@ -104,9 +102,3 @@ impl RequestHandler<DefaultRpcHandler> for DarkfiNode {
self.rpc_connections.lock().await
}
}
impl HandlerP2p for DarkfiNode {
fn p2p(&self) -> P2pPtr {
self.p2p_handler.p2p.clone()
}
}

View File

@@ -49,7 +49,7 @@ pub struct StratumRpcHandler;
#[rustfmt::skip]
impl RequestHandler<StratumRpcHandler> for DarkfiNode {
async fn handle_request(&self, req: JsonRequest) -> JsonResult {
debug!(target: "darkfid::stratum_rpc", "--> {}", req.stringify().unwrap());
debug!(target: "darkfid::rpc::stratum_rpc", "--> {}", req.stringify().unwrap());
match req.method.as_str() {
// ======================

View File

@@ -61,7 +61,7 @@ pub struct MmRpcHandler;
#[rustfmt::skip]
impl RequestHandler<MmRpcHandler> for DarkfiNode {
async fn handle_request(&self, req: JsonRequest) -> JsonResult {
debug!(target: "darkfid::mm_rpc", "--> {}", req.stringify().unwrap());
debug!(target: "darkfid::rpc::rpc_xmr", "--> {}", req.stringify().unwrap());
match req.method.as_str() {
// ================================================

View File

@@ -281,7 +281,11 @@ fn darkfid_programmatic_control() -> Result<()> {
checkpoint: None,
};
let rpc_settings = RpcSettings {
listen: Url::parse("tcp://127.0.0.1:8240").unwrap(),
listen: Url::parse("tcp://127.0.0.1:18245").unwrap(),
..RpcSettings::default()
};
let management_rpc_settings = RpcSettings {
listen: Url::parse("tcp://127.0.0.1:18246").unwrap(),
..RpcSettings::default()
};
@@ -298,13 +302,33 @@ fn darkfid_programmatic_control() -> Result<()> {
.unwrap();
// Start it
daemon.start(&ex, &rpc_settings, &None, &None, &consensus_config).await.unwrap();
daemon
.start(
&ex,
&rpc_settings,
&management_rpc_settings,
&None,
&None,
&consensus_config,
)
.await
.unwrap();
// Stop it
daemon.stop().await.unwrap();
// Start it again
daemon.start(&ex, &rpc_settings, &None, &None, &consensus_config).await.unwrap();
daemon
.start(
&ex,
&rpc_settings,
&management_rpc_settings,
&None,
&None,
&consensus_config,
)
.await
.unwrap();
// Stop it
daemon.stop().await.unwrap();

View File

@@ -19,19 +19,19 @@
#[[nodes]]
#name = "darkfid-testnet"
#host = "localhost"
#port = 8340
#port = 18346
#type = "NORMAL"
#[[nodes]]
#name = "darkfid-mainnet"
#host = "localhost"
#port = 8440
#port = 8346
#type = "NORMAL"
#[[nodes]]
#name = "darkfid-localnet"
#host = "localhost"
#port = 8240
#port = 28346
#type = "NORMAL"
#[[nodes]]

View File

@@ -24,7 +24,7 @@ wallet_path = "~/.local/share/darkfi/drk/localnet/wallet.db"
wallet_pass = "changeme"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8240"
endpoint = "tcp://127.0.0.1:28345"
# Path to interactive shell history file
history_path = "~/.local/share/darkfi/drk/localnet/history.txt"
@@ -41,7 +41,7 @@ wallet_path = "~/.local/share/darkfi/drk/testnet/wallet.db"
wallet_pass = "changeme"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8340"
endpoint = "tcp://127.0.0.1:18345"
# Path to interactive shell history file
history_path = "~/.local/share/darkfi/drk/testnet/history.txt"
@@ -58,7 +58,7 @@ wallet_path = "~/.local/share/darkfi/drk/mainnet/wallet.db"
wallet_pass = "changeme"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8440"
endpoint = "tcp://127.0.0.1:8345"
# Path to interactive shell history file
history_path = "~/.local/share/darkfi/drk/mainnet/history.txt"

View File

@@ -596,7 +596,7 @@ struct BlockchainNetwork {
/// Password for the wallet database
wallet_pass: String,
#[structopt(short, long, default_value = "tcp://127.0.0.1:8240")]
#[structopt(short, long, default_value = "tcp://127.0.0.1:28345")]
/// darkfid JSON-RPC endpoint
endpoint: Url,

View File

@@ -98,7 +98,7 @@ Upon successful initialization of the Explorer environment, confirmation message
[INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[INFO] - Synced Blocks: 9
[INFO] - Synced Transactions: 9
[INFO] - Connected Darkfi Node: tcp://127.0.0.1:8240
[INFO] - Connected Darkfi Node: tcp://127.0.0.1:28345
[INFO] ========================================================================================
[INFO] All is good. Waiting for block notifications...
Started explorer site on localnet network (PID=31911)

View File

@@ -72,19 +72,19 @@ make stop
When a DarkFi Explorer Node successfully starts, users should a startup banner displaying the node's configuration details and current sync status. Here is a successful localnet node startup example:
```
03:31:37 [INFO] ========================================================================================
03:31:37 [INFO] Started DarkFi Explorer Node
03:31:37 [INFO] ========================================================================================
03:31:37 [INFO] - Network: localnet
03:31:37 [INFO] - JSON-RPC Endpoint: tcp://127.0.0.1:14567
03:31:37 [INFO] - Database: ~/.local/share/darkfi/explorerd/localnet
03:31:37 [INFO] - Configuration: ./explorerd_config.toml
03:31:37 [INFO] - Reset Blocks: No
03:31:37 [INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
03:31:37 [INFO] - Synced Blocks: 8
03:31:37 [INFO] - Synced Transactions: 8
03:31:37 [INFO] - Connected Darkfi Node: tcp://127.0.0.1:8240
03:31:37 [INFO] ========================================================================================
[INFO] ========================================================================================
[INFO] Started DarkFi Explorer Node
[INFO] ========================================================================================
[INFO] - Network: localnet
[INFO] - JSON-RPC Endpoint: tcp://127.0.0.1:14567
[INFO] - Database: ~/.local/share/darkfi/explorerd/localnet
[INFO] - Configuration: ./explorerd_config.toml
[INFO] - Reset Blocks: No
[INFO] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[INFO] - Synced Blocks: 8
[INFO] - Synced Transactions: 8
[INFO] - Connected Darkfi Node: tcp://127.0.0.1:28345
[INFO] ========================================================================================
```
> **Note** In no-sync mode, you will see “Started DarkFi Explorer Node (No-Sync Mode)” in the banner header, and the “Connected Darkfi Node:” line will show “Not connected”.
@@ -113,7 +113,7 @@ Below is an example of a localnet configuration for `explorerd` (`~/.config/dark
database = "~/.local/share/darkfi/explorerd/localnet"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8240"
endpoint = "tcp://127.0.0.1:28345"
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
@@ -147,14 +147,14 @@ To create a custom explorerd configuration, use [Explorerd Configuration](../exp
```toml
[network_config."localnet".rpc]
rpc_listen = "tcp://127.0.0.1:8240"
rpc_listen = "tcp://127.0.0.1:28345"
```
- `explorerd_config.toml`:
```toml
[network_config."localnet"]
endpoint = "tcp://127.0.0.1:8240"
endpoint = "tcp://127.0.0.1:28345"
```
### Installation

View File

@@ -18,7 +18,7 @@ network = "testnet"
database = "~/.local/share/darkfi/explorerd/localnet"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8240"
endpoint = "tcp://127.0.0.1:28345"
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
@@ -37,7 +37,7 @@ rpc_listen = "tcp://127.0.0.1:14567"
database = "~/.local/share/darkfi/explorerd/testnet"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8340"
endpoint = "tcp://127.0.0.1:18345"
## Localnet JSON-RPC settings
[network_config."testnet".rpc]
@@ -55,7 +55,7 @@ rpc_listen = "tcp://127.0.0.1:14667"
database = "~/.local/share/darkfi/explorerd/mainnet"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8440"
endpoint = "tcp://127.0.0.1:8345"
## Localnet JSON-RPC settings
[network_config."mainnet".rpc]

View File

@@ -162,7 +162,7 @@ pub struct ExplorerNetworkConfig {
/// Path to the explorer's database.
pub database: String,
#[structopt(short, long, default_value = "tcp://127.0.0.1:8340")]
#[structopt(short, long, default_value = "tcp://127.0.0.1:28345")]
/// Endpoint of the DarkFi node JSON-RPC server to sync with.
pub endpoint: Url,
}
@@ -238,19 +238,19 @@ mod tests {
(
"localnet",
"~/.local/share/darkfi/explorerd/localnet",
"tcp://127.0.0.1:8240/",
"tcp://127.0.0.1:28345/",
"tcp://127.0.0.1:14567/",
),
(
"testnet",
"~/.local/share/darkfi/explorerd/testnet",
"tcp://127.0.0.1:8340/",
"tcp://127.0.0.1:18345/",
"tcp://127.0.0.1:14667/",
),
(
"mainnet",
"~/.local/share/darkfi/explorerd/mainnet",
"tcp://127.0.0.1:8440/",
"tcp://127.0.0.1:8345/",
"tcp://127.0.0.1:14767/",
),
];

View File

@@ -66,7 +66,7 @@ pub fn setup() -> Arc<Explorerd> {
let db_path_buf = temp_dir.path().join("explorerd_0");
let db_path =
db_path_buf.to_str().expect("Failed to convert db_path to string").to_string();
let darkfid_endpoint = Url::parse("http://127.0.0.1:8240").expect("Invalid URL");
let darkfid_endpoint = Url::parse("http://127.0.0.1:28345").expect("Invalid URL");
let executor = Arc::new(Executor::new());
// Block on the async function to resolve Explorerd::new

View File

@@ -16,7 +16,7 @@ rpc_listen = "tcp://127.0.0.1:18927"
## Per-network settings
#[network."darkfid_testnet_v5"]
#accept_addrs = ["tcp+tls://0.0.0.0:8342"]
#accept_addrs = ["tcp+tls://0.0.0.0:18345"]
#seeds = []
#peers = []
#version = "0.5.0"

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48240"
rpc_listen = "tcp://127.0.0.1:48345"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48241"
rpc_listen = "tcp://127.0.0.1:48346"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,4 +58,4 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48242"]
inbound = ["tcp+tls://0.0.0.0:48340"]

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48340"
rpc_listen = "tcp://127.0.0.1:48445"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48340"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48341"
rpc_listen = "tcp://127.0.0.1:48446"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48342"]
inbound = ["tcp+tls://0.0.0.0:48440"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242"]
peers = ["tcp+tls://0.0.0.0:48340"]

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48440"
rpc_listen = "tcp://127.0.0.1:48545"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48440"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48441"
rpc_listen = "tcp://127.0.0.1:48546"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48442"]
inbound = ["tcp+tls://0.0.0.0:48540"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342"]
peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440"]

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48540"
rpc_listen = "tcp://127.0.0.1:48645"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48540"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48541"
rpc_listen = "tcp://127.0.0.1:48646"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48542"]
inbound = ["tcp+tls://0.0.0.0:48640"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342", "tcp+tls://0.0.0.0:48442"]
peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440", "tcp+tls://0.0.0.0:48540"]

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48640"
rpc_listen = "tcp://127.0.0.1:48745"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48640"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48641"
rpc_listen = "tcp://127.0.0.1:48746"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,7 +58,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48642"]
inbound = ["tcp+tls://0.0.0.0:48740"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342", "tcp+tls://0.0.0.0:48442", "tcp+tls://0.0.0.0:48542"]
peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440", "tcp+tls://0.0.0.0:48540", "tcp+tls://0.0.0.0:48640"]

View File

@@ -20,23 +20,23 @@ else
fi
tmux new-session -d -s $session -n "node0"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48241 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48346 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid0.toml $verbose" Enter
tmux new-window -t $session -n "node1"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48341 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48446 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid1.toml $verbose" Enter
tmux new-window -t $session -n "node2"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48441 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48546 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid2.toml $verbose" Enter
tmux new-window -t $session -n "node3"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48541 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48646 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid3.toml $verbose" Enter
tmux new-window -t $session -n "node4"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48641 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48746 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid4.toml $verbose" Enter
tmux attach -t $session

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48240"
rpc_listen = "tcp://127.0.0.1:48345"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48241"
rpc_listen = "tcp://127.0.0.1:48346"
# Disabled RPC methods (stratum mining)
#rpc_disabled_methods = []
@@ -69,4 +69,4 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48242"]
inbound = ["tcp+tls://0.0.0.0:48340"]

View File

@@ -21,7 +21,7 @@ wallet_path = "drk/wallet.db"
wallet_pass = "testing"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:48240"
endpoint = "tcp://127.0.0.1:48345"
# Path to interactive shell history file
history_path = "drk/history.txt"

View File

@@ -5,7 +5,7 @@ set -e
# xmrig configuration
XMRIG_BINARY_PATH="xmrig"
XMRIG_STRATUM_ENDPOINT="127.0.0.1:48241"
XMRIG_STRATUM_ENDPOINT="127.0.0.1:48346"
XMRIG_THREADS="4"
XMRIG_USER="DZnsGMCvZU5CEzvpuExnxbvz6SEhE2rn89sMcuHsppFE6TjL4SBTrKkf"
XMRIG_PARAMS="-u x+1 -r 1000 -R 20 -o $XMRIG_STRATUM_ENDPOINT -t $XMRIG_THREADS -u $XMRIG_USER"

View File

@@ -38,7 +38,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48240"
rpc_listen = "tcp://127.0.0.1:48345"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -46,7 +46,7 @@ rpc_listen = "tcp://127.0.0.1:48240"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48241"
rpc_listen = "tcp://127.0.0.1:48346"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -58,4 +58,4 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48242"]
inbound = ["tcp+tls://0.0.0.0:48340"]

View File

@@ -46,7 +46,7 @@ skip_fees = false
## Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48340"
rpc_listen = "tcp://127.0.0.1:48445"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -54,7 +54,7 @@ rpc_listen = "tcp://127.0.0.1:48340"
## Localnet JSON-RPC settings for stratum mining requests (optional)
[network_config."localnet".stratum_rpc]
# JSON-RPC listen URL (stratum mining)
rpc_listen = "tcp://127.0.0.1:48341"
rpc_listen = "tcp://127.0.0.1:48446"
## Localnet P2P network settings
[network_config."localnet".net]
@@ -66,7 +66,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48342"]
inbound = ["tcp+tls://0.0.0.0:48440"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242"]
peers = ["tcp+tls://0.0.0.0:48340"]

View File

@@ -38,7 +38,7 @@ skip_fees = false
# Localnet JSON-RPC settings
[network_config."localnet".rpc]
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48440"
rpc_listen = "tcp://127.0.0.1:48545"
# Disabled RPC methods
#rpc_disabled_methods = ["p2p.get_info"]
@@ -53,7 +53,7 @@ active_profiles = ["tcp+tls"]
[network_config."localnet".net.profiles."tcp+tls"]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48442"]
inbound = ["tcp+tls://0.0.0.0:48540"]
# Peer nodes to manually connect to
peers = ["tcp+tls://0.0.0.0:48242", "tcp+tls://0.0.0.0:48342"]
peers = ["tcp+tls://0.0.0.0:48340", "tcp+tls://0.0.0.0:48440"]

View File

@@ -21,11 +21,11 @@ else
fi
tmux new-session -d -s $session -n "node0"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48241 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48346 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid0.toml $verbose" Enter
tmux new-window -t $session -n "node1"
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48341 -t 2 -u $XMRIG_USER" Enter
tmux send-keys -t $session "$XMRIG -u x+1 -r 1000 -R 20 -o 127.0.0.1:48446 -t 2 -u $XMRIG_USER" Enter
tmux split-window -t $session -v -l 80%
tmux send-keys -t $session "$DARKFID -c darkfid1.toml $verbose" Enter
tmux new-window -t $session -n "node2"

View File

@@ -21,7 +21,7 @@ $(DARKFID_JSONRPC):
@echo "# darkfid JSON-RPC API" > $@
@echo "## Methods" >> $@
@echo "<!-- toc -->" >> $@
for i in blockchain tx stratum xmr misc; do \
for i in blockchain tx stratum xmr misc management; do \
echo "## $$i methods" >> $@ ;\
./build_jsonrpc.py ../bin/darkfid/src/rpc/$$i.rs >> $@ ;\
done

View File

@@ -731,7 +731,7 @@ DarkFi DAO mining configuration address:
Then start an `xmrig` instance to mine for the DAO:
```shell
$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:8341 -t {XMRIG_THREADS} -u {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION}
$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:18347 -t {XMRIG_THREADS} -u {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION}
```
After your miners have successfully mined confirmed blocks, you will

View File

@@ -187,21 +187,16 @@ endpoint that will be used by `p2pool` in `darkfid` config:
```toml
[network_config."testnet".mm_rpc]
rpc_listen = "http+tcp://127.0.0.1:8341"
rpc_listen = "http+tcp://127.0.0.1:18348"
```
> Note:
>
> If you are also using a `Stratum` RPC endpoint make sure the two
> ports are different.
Then start `darkfid` as usual.
Stop `p2pool` if it's running, and re-run it with the merge-mining
parameters appended:
```shell
$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:8341 {YOUR_DARKFI_WALLET_ADDRESS}
$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:18348 {YOUR_DARKFI_WALLET_ADDRESS}
```
Now `p2pool` should communicate with both `monerod` and `darkfid` in
@@ -229,7 +224,7 @@ Stop `p2pool` if it's running, and re-run it with the merge-mining
parameters appended:
```shell
$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_DAO_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:8341 {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION}
$ ./p2pool --host 127.0.0.1 --rpc-port 28081 --zmq-port 28083 --wallet {YOUR_DAO_MONERO_WALLET_ADDRESS_HERE} --stratum 127.0.0.1:3333 --data-dir ./p2pool-data --no-igd --merge-mine 127.0.0.1:18348 {YOUR_DAO_WALLET_ADDRESS_MINING_CONFIGURATION}
```
After your miners have successfully mined confirmed blocks, you will

View File

@@ -256,7 +256,7 @@ config:
```toml
[network_config."testnet".stratum_rpc]
rpc_listen = "tcp://127.0.0.1:8341"
rpc_listen = "tcp://127.0.0.1:18347"
```
> Note:
@@ -285,7 +285,7 @@ for maximum mining performance. Start `darkfid` as usual and then start
which wallet:
```shell
$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:8341 -t {XMRIG_THREADS} -u {YOUR_DARKFI_WALLET_ADDRESS}
$ ./xmrig -u x+1 -r 1000 -R 20 -o 127.0.0.1:18347 -t {XMRIG_THREADS} -u {YOUR_DARKFI_WALLET_ADDRESS}
```
In `darkfid`, you should see a notification like this:

View File

@@ -7,7 +7,7 @@
## uncommenting, or by using the command-line.
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:8340"
endpoint = "tcp://127.0.0.1:28345"
# Block height to measure until
height = 0

View File

@@ -44,7 +44,7 @@ struct Args {
/// Configuration file to use
config: Option<String>,
#[structopt(short, long, default_value = "tcp://127.0.0.1:8340")]
#[structopt(short, long, default_value = "tcp://127.0.0.1:28345")]
/// darkfid JSON-RPC endpoint
endpoint: Url,