Add a removeEventListener method. Idea from Andreas. Resolves issue 27.

This commit is contained in:
Mike Hearn 2011-07-06 12:44:18 +00:00
parent 2e2c941919
commit 1f5922b2f4

View file

@ -338,7 +338,10 @@ public class Wallet implements Serializable {
// A -> spent by B [pending] // A -> spent by B [pending]
// \-> spent by C [chain] // \-> spent by C [chain]
Transaction doubleSpent = input.outpoint.fromTx; // == A Transaction doubleSpent = input.outpoint.fromTx; // == A
Transaction connected = doubleSpent.outputs.get((int)input.outpoint.index).getSpentBy().parentTransaction; int index = (int) input.outpoint.index;
TransactionOutput output = doubleSpent.outputs.get(index);
TransactionInput spentBy = output.getSpentBy();
Transaction connected = spentBy.parentTransaction;
if (pending.containsKey(connected.getHash())) { if (pending.containsKey(connected.getHash())) {
log.info("Saw double spend from chain override pending tx {}", connected.getHashAsString()); log.info("Saw double spend from chain override pending tx {}", connected.getHashAsString());
log.info(" <-pending ->dead"); log.info(" <-pending ->dead");
@ -382,6 +385,14 @@ public class Wallet implements Serializable {
eventListeners.add(listener); eventListeners.add(listener);
} }
/**
* Removes the given event listener object. Returns true if the listener was removed,
* false if that listener was never added.
*/
public synchronized boolean removeEventListener(WalletEventListener listener) {
return eventListeners.remove(listener);
}
/** /**
* Call this when we have successfully transmitted the send tx to the network, to update the wallet. * Call this when we have successfully transmitted the send tx to the network, to update the wallet.
*/ */