Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from CounterpartyXCP/hostname
Browse files Browse the repository at this point in the history
Accept host name for `--backend-connect`
  • Loading branch information
adamkrellenstein authored Mar 20, 2024
2 parents ed1ef0a + c923e7e commit 037c52e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ doc = "Indexer JSONRPC 'port' to listen on (default: '50001' for mainnet, '60001

[[param]]
name = "daemon_rpc_host"
type = "std::net::Ipv4Addr"
type = "String"
doc = "Bitcoin daemon JSONRPC 'host' to connect (default: 127.0.0.1 for mainnet, 127.0.0.1 for testnet and 127.0.0.1 for regtest)"

[[param]]
Expand Down
9 changes: 7 additions & 2 deletions src/bin/addrindexrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate error_chain;
extern crate log;

use error_chain::ChainedError;
use std::net::{IpAddr, SocketAddr};
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
use std::process;
use std::sync::Arc;
use std::time::Duration;
Expand All @@ -24,13 +24,18 @@ use addrindexrs::{
store::{full_compaction, is_fully_compacted, DBStore},
};



fn run_server(config: &Config) -> Result<()> {
let signal = Waiter::start();
let blocktxids_cache = Arc::new(BlockTxIDsCache::new(config.blocktxids_cache_size));

let daemon_rpc = config.daemon_rpc_host.as_str().to_owned() + ":" + &config.daemon_rpc_port.to_string();

let daemon = Daemon::new(
&config.daemon_dir,
SocketAddr::new(IpAddr::V4(config.daemon_rpc_host), config.daemon_rpc_port),
daemon_rpc.as_str().to_socket_addrs().unwrap().next().unwrap(),
//SocketAddr::new(config.daemon_rpc_host, config.daemon_rpc_port),
config.cookie_getter(),
config.network_type,
signal.clone(),
Expand Down
5 changes: 3 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::errors::*;
// Default IP address of the RPC server
//
const DEFAULT_SERVER_ADDRESS: [u8; 4] = [127, 0, 0, 1]; // by default, serve on IPv4 localhost
const DEFAULT_SERVER_ADDRESS_STRING: &str = "127.0.0.1"; // by default, serve on IPv4 localhost

mod internal {
#![allow(unused)]
Expand Down Expand Up @@ -96,7 +97,7 @@ pub struct Config {
pub network_type: Network,
pub db_path: PathBuf,
pub daemon_dir: PathBuf,
pub daemon_rpc_host: Ipv4Addr,
pub daemon_rpc_host: String,
pub daemon_rpc_port: u16,
pub cookie: Option<String>,
pub indexer_rpc_host: Ipv4Addr,
Expand Down Expand Up @@ -160,7 +161,7 @@ impl Config {

let daemon_rpc_host = config
.daemon_rpc_host
.unwrap_or(DEFAULT_SERVER_ADDRESS.into());
.unwrap_or(DEFAULT_SERVER_ADDRESS_STRING.into());
let daemon_rpc_port = config.daemon_rpc_port.unwrap_or(default_daemon_port);

let indexer_rpc_host = config
Expand Down

0 comments on commit 037c52e

Please sign in to comment.