From caa92985e165fe504b2a8a0bef8e3333af3e3a86 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Sun, 20 Jan 2013 23:47:32 +0100 Subject: [PATCH] When broadcasting a spend, wait for the tx message to actually hit the wire before proceeding. This resolves an issue where wallet-tool would shut down before the message was actually sent. --- core/src/main/java/com/google/bitcoin/core/Peer.java | 4 ++-- core/src/main/java/com/google/bitcoin/core/PeerGroup.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Peer.java b/core/src/main/java/com/google/bitcoin/core/Peer.java index 9d397373..3f9cd185 100644 --- a/core/src/main/java/com/google/bitcoin/core/Peer.java +++ b/core/src/main/java/com/google/bitcoin/core/Peer.java @@ -605,8 +605,8 @@ public class Peer { /** * Sends the given message on the peers Channel. */ - public void sendMessage(Message m) throws IOException { - Channels.write(channel, m); + public ChannelFuture sendMessage(Message m) throws IOException { + return Channels.write(channel, m); } // Keep track of the last request we made to the peer in blockChainDownload so we can avoid redundant and harmful diff --git a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java index 33c4bbaa..ab17db1a 100644 --- a/core/src/main/java/com/google/bitcoin/core/PeerGroup.java +++ b/core/src/main/java/com/google/bitcoin/core/PeerGroup.java @@ -968,7 +968,7 @@ public class PeerGroup extends AbstractIdleService { // transaction or not. However, we are not a fully validating node and this is advertised in // our version message, as SPV nodes cannot relay it doesn't give away any additional information // to skip the inv here - we wouldn't send invs anyway. - somePeer.sendMessage(pinnedTx); + somePeer.sendMessage(pinnedTx).awaitUninterruptibly(); } catch (IOException e) { future.setException(e); return;