Skip to content

Commit

Permalink
Merge #46: Enable running multiple Core v28 nodes
Browse files Browse the repository at this point in the history
5dcfd5f Enable running multiple Core v28 nodes (Tobin C. Harding)

Pull request description:

  Currently the `node` crate cannot run multiple instances of Bitcoin Core v28 because of changes to bind logic in that release.

  The solution is to use `-bind` instead of `-port`.

  For more information on the relevant changes in Core v28 see:

  https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-28.0.md#p2p-and-network-changes

  This patch was created with help of MaxFangX - mad props.

  Fix: #41

ACKs for top commit:
  apoelstra:
    ACK 5dcfd5f; successfully ran local tests; thanks guys!

Tree-SHA512: d639c09add6d313975a8abc8caaeb5afb9fbfd0e09a39a854aab91aafd50f056ceb8318b5c3dd4ae22955c325c6b593eec9f6de8eec3b7e3e9039b754cfadb86
  • Loading branch information
apoelstra committed Jan 23, 2025
2 parents 0a9555f + 5dcfd5f commit a19e9ea
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ impl Node {
P2P::Yes => {
let p2p_port = get_available_port()?;
let p2p_socket = SocketAddrV4::new(LOCAL_IP, p2p_port);
let p2p_arg = format!("-port={}", p2p_port);
let args = vec![p2p_arg];
let bind_arg = format!("-bind={}", p2p_socket);
let args = vec![bind_arg];
(args, Some(p2p_socket))
}
P2P::Connect(other_node_url, listen) => {
let p2p_port = get_available_port()?;
let p2p_socket = SocketAddrV4::new(LOCAL_IP, p2p_port);
let p2p_arg = format!("-port={}", p2p_port);
let bind_arg = format!("-bind={}", p2p_socket);
let connect = format!("-connect={}", other_node_url);
let mut args = vec![p2p_arg, connect];
let mut args = vec![bind_arg, connect];
if listen {
args.push("-listen=1".to_string())
}
Expand Down Expand Up @@ -674,22 +674,6 @@ mod test {
}

#[test]
// In v28:
//
// > Bitcoin Core will now fail to start up if any of its P2P binds fail, rather than the
// > previous behaviour where it would only abort startup if all P2P binds had failed.
//
// ref: https://bitcoincore.org/en/releases/28.0/
// ref: https://github.com/bitcoin/bitcoin/pull/22729
//
// I tried various things to stop bitcoind attempting to bind on 18445 but could get nothing to work.
//
// - Tried using arg `-torcontrol=0`.
// - Tried using arg `-listenonion=0`.
// - Tried using arg `-bind={available_port}`.
// - Tried using arg `-bind={available_port}=onion`.
// - Tried using both the two bind args above together.
#[cfg(not(feature = "28_0"))]
fn test_multi_p2p() {
let exe = init();

Expand Down

0 comments on commit a19e9ea

Please sign in to comment.