@Test public void events() throws Exception { final TransactionConfidence.Listener.ChangeReason[] run = new TransactionConfidence.Listener.ChangeReason[1]; tx1.getConfidence().addEventListener(Threading.SAME_THREAD, new TransactionConfidence.Listener() { @Override public void onConfidenceChanged(TransactionConfidence confidence, ChangeReason reason) { run[0] = reason; } }); table.seen(tx1.getTxId(), address1); assertEquals(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS, run[0]); run[0] = null; table.seen(tx1.getTxId(), address1); assertNull(run[0]); }
public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) { TransactionConfidence confidence; boolean fresh = false; lock.lock(); try { cleanTable(); confidence = getOrCreate(hash); fresh = confidence.markBroadcastBy(byPeer); } finally { lock.unlock(); } if (fresh) confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS); return confidence; }
TxConfidenceTable { public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) { TransactionConfidence confidence; boolean fresh = false; lock.lock(); try { cleanTable(); confidence = getOrCreate(hash); fresh = confidence.markBroadcastBy(byPeer); } finally { lock.unlock(); } if (fresh) confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS); return confidence; } }
TxConfidenceTable { public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) { TransactionConfidence confidence; boolean fresh = false; lock.lock(); try { cleanTable(); confidence = getOrCreate(hash); fresh = confidence.markBroadcastBy(byPeer); } finally { lock.unlock(); } if (fresh) confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS); return confidence; } TxConfidenceTable(final int size);   TxConfidenceTable(final int size, TransactionConfidence.Factory confidenceFactory);  TxConfidenceTable(); }
TxConfidenceTable { public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) { TransactionConfidence confidence; boolean fresh = false; lock.lock(); try { cleanTable(); confidence = getOrCreate(hash); fresh = confidence.markBroadcastBy(byPeer); } finally { lock.unlock(); } if (fresh) confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS); return confidence; } TxConfidenceTable(final int size);   TxConfidenceTable(final int size, TransactionConfidence.Factory confidenceFactory);  TxConfidenceTable(); int numBroadcastPeers(Sha256Hash txHash); TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer); TransactionConfidence getOrCreate(Sha256Hash hash); @Nullable TransactionConfidence get(Sha256Hash hash); }
TxConfidenceTable { public TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer) { TransactionConfidence confidence; boolean fresh = false; lock.lock(); try { cleanTable(); confidence = getOrCreate(hash); fresh = confidence.markBroadcastBy(byPeer); } finally { lock.unlock(); } if (fresh) confidence.queueListeners(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS); return confidence; } TxConfidenceTable(final int size);   TxConfidenceTable(final int size, TransactionConfidence.Factory confidenceFactory);  TxConfidenceTable(); int numBroadcastPeers(Sha256Hash txHash); TransactionConfidence seen(Sha256Hash hash, PeerAddress byPeer); TransactionConfidence getOrCreate(Sha256Hash hash); @Nullable TransactionConfidence get(Sha256Hash hash); static final int MAX_SIZE; }