From e8138c21b02b33511807c947df52af2a933cc59f Mon Sep 17 00:00:00 2001 From: Adam Mackler Date: Wed, 4 Feb 2015 06:06:27 -0500 Subject: [PATCH] Change PeerGroup.addPeerFilterProvider to return a ListenableFuture Currently 'addPeerFilterProvider()` returns `void`. After this patch it returns the `ListenableFuture` that is returned by its invocation of `recalculateFastCatchupAndFilter()`. --- core/src/main/java/org/bitcoinj/core/PeerGroup.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index ee71e492..39f1a99e 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -961,8 +961,14 @@ public class PeerGroup implements TransactionBroadcaster { * *

Note that this should be done before chain download commences because if you add a listener with keys earlier * than the current chain head, the relevant parts of the chain won't be redownloaded for you.

+ * + *

This method invokes {@link PeerGroup#recalculateFastCatchupAndFilter(FilterRecalculateMode)}. + * The return value of this method is the ListenableFuture returned by that invocation.

+ * + * @return a future that completes once each Peer in this group has had its + * BloomFilter (re)set. */ - public void addPeerFilterProvider(PeerFilterProvider provider) { + public ListenableFuture addPeerFilterProvider(PeerFilterProvider provider) { lock.lock(); try { checkNotNull(provider); @@ -981,8 +987,9 @@ public class PeerGroup implements TransactionBroadcaster { // if a key is added. Of course, by then we may have downloaded the chain already. Ideally adding keys would // automatically rewind the block chain and redownload the blocks to find transactions relevant to those keys, // all transparently and in the background. But we are a long way from that yet. - recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); + ListenableFuture future = recalculateFastCatchupAndFilter(FilterRecalculateMode.SEND_IF_CHANGED); updateVersionMessageRelayTxesBeforeFilter(getVersionMessage()); + return future; } finally { lock.unlock(); }