3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00

Always pass the wallet into the event listeners on every event.

This commit is contained in:
Mike Hearn 2011-09-18 20:14:14 +00:00
parent bbe133be88
commit a3a4a927af
5 changed files with 13 additions and 13 deletions

View File

@ -51,7 +51,7 @@ public abstract class AbstractWalletEventListener implements WalletEventListener
*
* TODO: Finish this interface.
*/
public void onReorganize() {
public void onReorganize(Wallet wallet) {
onChange();
}
@ -68,7 +68,7 @@ public abstract class AbstractWalletEventListener implements WalletEventListener
* @param deadTx The transaction that is newly dead.
* @param replacementTx The transaction that killed it.
*/
public void onDeadTransaction(Transaction deadTx, Transaction replacementTx) {
public void onDeadTransaction(Wallet wallet, Transaction deadTx, Transaction replacementTx) {
onChange();
}

View File

@ -294,8 +294,8 @@ public class Wallet implements Serializable {
log.info("Balance is now: " + bitcoinValueToFriendlyString(getBalance()));
// Inform anyone interested that we have new coins. Note: we may be re-entered by the event listener,
// so we must not make assumptions about our state after this loop returns! For example,
// the balance we just received might already be spent!
// so we must not make assumptions about our state after this loop returns! For example the balance we just
// received might already be spent!
if (!reorg && bestChain && valueDifference.compareTo(BigInteger.ZERO) > 0) {
for (WalletEventListener l : eventListeners) {
synchronized (l) {
@ -370,7 +370,7 @@ public class Wallet implements Serializable {
// Inform the event listeners of the newly dead tx.
for (WalletEventListener listener : eventListeners) {
synchronized (listener) {
listener.onDeadTransaction(connected, tx);
listener.onDeadTransaction(this, connected, tx);
}
}
}
@ -928,7 +928,7 @@ public class Wallet implements Serializable {
// Synchronize on the event listener as well. This allows a single listener to handle events from
// multiple wallets without needing to worry about being thread safe.
synchronized (l) {
l.onReorganize();
l.onReorganize(this);
}
}
}
@ -962,7 +962,7 @@ public class Wallet implements Serializable {
// Inform the event listeners of the newly dead tx.
for (WalletEventListener listener : eventListeners) {
synchronized (listener) {
listener.onDeadTransaction(tx, replacement);
listener.onDeadTransaction(this, tx, replacement);
}
}
break;

View File

@ -50,7 +50,7 @@ public interface WalletEventListener {
*
* TODO: Finish this interface.
*/
void onReorganize();
void onReorganize(Wallet wallet);
/**
* This is called on a Peer thread when a transaction becomes <i>dead</i>. A dead transaction is one that has
@ -64,5 +64,5 @@ public interface WalletEventListener {
* @param deadTx The transaction that is newly dead.
* @param replacementTx The transaction that killed it.
*/
void onDeadTransaction(Transaction deadTx, Transaction replacementTx);
void onDeadTransaction(Wallet wallet, Transaction deadTx, Transaction replacementTx);
}

View File

@ -53,7 +53,7 @@ public class ChainSplitTests {
reorgHappened[0] = false;
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onReorganize() {
public void onReorganize(Wallet wallet) {
reorgHappened[0] = true;
}
});
@ -187,7 +187,7 @@ public class ChainSplitTests {
final boolean[] eventCalled = new boolean[1];
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onDeadTransaction(Transaction deadTx, Transaction replacementTx) {
public void onDeadTransaction(Wallet wallet, Transaction deadTx, Transaction replacementTx) {
eventCalled[0] = true;
}
});
@ -227,7 +227,7 @@ public class ChainSplitTests {
final Transaction[] eventReplacement = new Transaction[1];
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onDeadTransaction(Transaction deadTx, Transaction replacementTx) {
public void onDeadTransaction(Wallet wallet, Transaction deadTx, Transaction replacementTx) {
eventDead[0] = deadTx;
eventReplacement[0] = replacementTx;
}

View File

@ -251,7 +251,7 @@ public class WalletTest {
final Transaction[] eventReplacement = new Transaction[1];
wallet.addEventListener(new AbstractWalletEventListener() {
@Override
public void onDeadTransaction(Transaction deadTx, Transaction replacementTx) {
public void onDeadTransaction(Wallet wallet, Transaction deadTx, Transaction replacementTx) {
eventDead[0] = deadTx;
eventReplacement[0] = replacementTx;
}