Wallet: flip argument ordering in deprecated Wallet.addEventListener to restore compatibility with 0.13

This commit is contained in:
Mike Hearn
2015-10-05 17:12:55 +02:00
parent 0342feee86
commit 9ba1be762a
6 changed files with 16 additions and 20 deletions

View File

@@ -1064,7 +1064,7 @@ public class PeerGroup implements TransactionBroadcaster {
checkState(!wallets.contains(wallet));
wallets.add(wallet);
wallet.setTransactionBroadcaster(this);
wallet.addEventListener(Threading.SAME_THREAD, walletEventListener);
wallet.addEventListener(walletEventListener, Threading.SAME_THREAD);
addPeerFilterProvider(wallet);
for (Peer peer : peers) {
peer.addWallet(wallet);

View File

@@ -2338,11 +2338,9 @@ public class Wallet extends BaseTaggableObject
coinListeners.add(new ListenerRegistration<WalletCoinEventListener>(listener, executor));
}
/**
* Adds an event listener object. Methods on this object are called when something interesting happens,
* like receiving money. The listener is executed by the given executor.
*/
public void addEventListener(Executor executor, WalletEventListener listener) {
/** Use the more specific listener methods instead */
@Deprecated
public void addEventListener(WalletEventListener listener, Executor executor) {
addCoinEventListener(executor, listener);
addChangeEventListener(executor, listener);
}

View File

@@ -173,7 +173,7 @@ public class PaymentChannelClientState {
if (storedChannel != null && storedChannel.close != null) {
watchCloseConfirmations();
}
wallet.addEventListener(Threading.SAME_THREAD, new AbstractWalletEventListener() {
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
synchronized (PaymentChannelClientState.this) {
@@ -189,7 +189,7 @@ public class PaymentChannelClientState {
}
}
}
});
}, Threading.SAME_THREAD);
}
private void watchCloseConfirmations() {

View File

@@ -557,12 +557,12 @@ public class ChainSplitTest {
// transactions would be. Also check that a dead coinbase on a sidechain is resurrected if the sidechain
// becomes the best chain once more. Finally, check that dependent transactions are killed recursively.
final ArrayList<Transaction> txns = new ArrayList<Transaction>(3);
wallet.addEventListener(Threading.SAME_THREAD, new AbstractWalletEventListener() {
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
txns.add(tx);
}
});
}, Threading.SAME_THREAD);
Block b1 = unitTestParams.getGenesisBlock().createNextBlock(someOtherGuy);
final ECKey coinsTo2 = wallet.freshReceiveKey();

View File

@@ -3015,12 +3015,12 @@ public class WalletTest extends TestWithWallet {
// Check that we can register an event listener, generate some keys and the callbacks are invoked properly.
wallet = new Wallet(params);
final List<ECKey> keys = Lists.newLinkedList();
wallet.addEventListener(Threading.SAME_THREAD, new AbstractWalletEventListener() {
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onKeysAdded(List<ECKey> k) {
keys.addAll(k);
}
});
}, Threading.SAME_THREAD);
wallet.freshReceiveKey();
assertEquals(1, keys.size());
}

View File

@@ -28,15 +28,13 @@ public class BitcoinUIModel {
}
public void setWallet(Wallet wallet) {
wallet.addEventListener(Platform::runLater,
new AbstractWalletEventListener() {
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onWalletChanged(Wallet wallet) {
super.onWalletChanged(wallet);
update(wallet);
}
}
);
}, Platform::runLater);
update(wallet);
}