Skip to content

Commit a19e9ea

Browse files
committed
Merge rust-bitcoin#46: Enable running multiple Core v28 nodes
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: rust-bitcoin#41 ACKs for top commit: apoelstra: ACK 5dcfd5f; successfully ran local tests; thanks guys! Tree-SHA512: d639c09add6d313975a8abc8caaeb5afb9fbfd0e09a39a854aab91aafd50f056ceb8318b5c3dd4ae22955c325c6b593eec9f6de8eec3b7e3e9039b754cfadb86
2 parents 0a9555f + 5dcfd5f commit a19e9ea

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

node/src/lib.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,16 @@ impl Node {
307307
P2P::Yes => {
308308
let p2p_port = get_available_port()?;
309309
let p2p_socket = SocketAddrV4::new(LOCAL_IP, p2p_port);
310-
let p2p_arg = format!("-port={}", p2p_port);
311-
let args = vec![p2p_arg];
310+
let bind_arg = format!("-bind={}", p2p_socket);
311+
let args = vec![bind_arg];
312312
(args, Some(p2p_socket))
313313
}
314314
P2P::Connect(other_node_url, listen) => {
315315
let p2p_port = get_available_port()?;
316316
let p2p_socket = SocketAddrV4::new(LOCAL_IP, p2p_port);
317-
let p2p_arg = format!("-port={}", p2p_port);
317+
let bind_arg = format!("-bind={}", p2p_socket);
318318
let connect = format!("-connect={}", other_node_url);
319-
let mut args = vec![p2p_arg, connect];
319+
let mut args = vec![bind_arg, connect];
320320
if listen {
321321
args.push("-listen=1".to_string())
322322
}
@@ -674,22 +674,6 @@ mod test {
674674
}
675675

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

0 commit comments

Comments
 (0)