(API CHANGE) Return a TransactionBroadcast object from PeerGroup.broadcastTransaction.

Old code can be updated by simply calling future() on the returned object to get the previous result.

TransactionBroadcast now has a progress reporting interface, which is ideal for connection to progress bars, pie charts, whatever else you want to use in the UI for showing the progress of sending money/broadcasting a tx.
This commit is contained in:
Mike Hearn
2015-02-20 15:01:54 +01:00
parent 298cccfe4f
commit bef4980abd
11 changed files with 129 additions and 34 deletions

View File

@@ -58,7 +58,7 @@ public class TestFeeLevel {
kit.wallet().completeTx(request);
log.info("Fee paid is {}", request.fee);
log.info("TX is {}", request.tx);
kit.peerGroup().broadcastTransaction(request.tx).get();
kit.peerGroup().broadcastTransaction(request.tx).future().get();
log.info("Send complete, waiting for confirmation");
request.tx.getConfidence().getDepthFuture(1).get();

View File

@@ -588,7 +588,7 @@ public class WalletTool {
// Wait for peers to connect, the tx to be sent to one of them and for it to be propagated across the
// network. Once propagation is complete and we heard the transaction back from all our peers, it will
// be committed to the wallet.
peers.broadcastTransaction(t).get();
peers.broadcastTransaction(t).future().get();
// Hack for regtest/single peer mode, as we're about to shut down and won't get an ACK from the remote end.
List<Peer> peerList = peers.getConnectedPeers();
if (peerList.size() == 1)
@@ -701,7 +701,7 @@ public class WalletTool {
if (future == null) {
// No payment_url for submission so, broadcast and wait.
peers.start();
peers.broadcastTransaction(req.tx).get();
peers.broadcastTransaction(req.tx).future().get();
} else {
PaymentProtocol.Ack ack = future.get();
wallet.commitTx(req.tx);