/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ @Nullable public TransactionConfidence get(Sha256Hash hash) { lock.lock(); try { WeakConfidenceReference ref = table.get(hash); if (ref == null) return null; TransactionConfidence confidence = ref.get(); if (confidence != null) return confidence; else return null; } finally { lock.unlock(); } } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ @Nullable public TransactionConfidence get(Sha256Hash hash) { lock.lock(); try { WeakConfidenceReference ref = table.get(hash); if (ref == null) return null; TransactionConfidence confidence = ref.get(); if (confidence != null) return confidence; else return null; } finally { lock.unlock(); } } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ @Nullable public TransactionConfidence get(Sha256Hash hash) { lock.lock(); try { WeakConfidenceReference ref = table.get(hash); if (ref == null) return null; TransactionConfidence confidence = ref.get(); if (confidence != null) return confidence; else return null; } finally { lock.unlock(); } } }
/** * Returns the number of peers that have seen the given hash recently. */ public int numBroadcastPeers(Sha256Hash txHash) { lock.lock(); try { cleanTable(); WeakConfidenceReference entry = table.get(txHash); if (entry == null) { return 0; // No such TX known. } else { TransactionConfidence confidence = entry.get(); if (confidence == null) { // Such a TX hash was seen, but nothing seemed to care so we ended up throwing away the data. table.remove(txHash); return 0; } else { return confidence.numBroadcastPeers(); } } } finally { lock.unlock(); } }
/** * Returns the number of peers that have seen the given hash recently. */ public int numBroadcastPeers(Sha256Hash txHash) { lock.lock(); try { cleanTable(); WeakConfidenceReference entry = table.get(txHash); if (entry == null) { return 0; // No such TX known. } else { TransactionConfidence confidence = entry.get(); if (confidence == null) { // Such a TX hash was seen, but nothing seemed to care so we ended up throwing away the data. table.remove(txHash); return 0; } else { return confidence.numBroadcastPeers(); } } } finally { lock.unlock(); } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ public TransactionConfidence getOrCreate(Sha256Hash hash) { checkNotNull(hash); lock.lock(); try { WeakConfidenceReference reference = table.get(hash); if (reference != null) { TransactionConfidence confidence = reference.get(); if (confidence != null) return confidence; } TransactionConfidence newConfidence = new TransactionConfidence(hash); table.put(hash, new WeakConfidenceReference(newConfidence, referenceQueue)); return newConfidence; } finally { lock.unlock(); } }
/** * Returns the number of peers that have seen the given hash recently. */ public int numBroadcastPeers(Sha256Hash txHash) { lock.lock(); try { cleanTable(); WeakConfidenceReference entry = table.get(txHash); if (entry == null) { return 0; // No such TX known. } else { TransactionConfidence confidence = entry.get(); if (confidence == null) { // Such a TX hash was seen, but nothing seemed to care so we ended up throwing away the data. table.remove(txHash); return 0; } else { return confidence.numBroadcastPeers(); } } } finally { lock.unlock(); } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ @Nullable public TransactionConfidence get(Sha256Hash hash) { lock.lock(); try { WeakConfidenceReference ref = table.get(hash); if (ref == null) return null; TransactionConfidence confidence = ref.get(); if (confidence != null) return confidence; else return null; } finally { lock.unlock(); } } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ public TransactionConfidence getOrCreate(Sha256Hash hash) { checkNotNull(hash); lock.lock(); try { WeakConfidenceReference reference = table.get(hash); if (reference != null) { TransactionConfidence confidence = reference.get(); if (confidence != null) return confidence; } TransactionConfidence newConfidence = new TransactionConfidence(hash); table.put(hash, new WeakConfidenceReference(newConfidence, referenceQueue)); return newConfidence; } finally { lock.unlock(); } }
/** * Returns the number of peers that have seen the given hash recently. */ public int numBroadcastPeers(Sha256Hash txHash) { lock.lock(); try { cleanTable(); WeakConfidenceReference entry = table.get(txHash); if (entry == null) { return 0; // No such TX known. } else { TransactionConfidence confidence = entry.get(); if (confidence == null) { // Such a TX hash was seen, but nothing seemed to care so we ended up throwing away the data. table.remove(txHash); return 0; } else { return confidence.numBroadcastPeers(); } } } finally { lock.unlock(); } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ public TransactionConfidence getOrCreate(Sha256Hash hash) { checkNotNull(hash); lock.lock(); try { WeakConfidenceReference reference = table.get(hash); if (reference != null) { TransactionConfidence confidence = reference.get(); if (confidence != null) return confidence; } TransactionConfidence newConfidence = new TransactionConfidence(hash); table.put(hash, new WeakConfidenceReference(newConfidence, referenceQueue)); return newConfidence; } finally { lock.unlock(); } }
/** * Returns the {@link TransactionConfidence} for the given hash if we have downloaded it, or null if that tx hash * is unknown to the system at this time. */ public TransactionConfidence getOrCreate(Sha256Hash hash) { checkNotNull(hash); lock.lock(); try { WeakConfidenceReference reference = table.get(hash); if (reference != null) { TransactionConfidence confidence = reference.get(); if (confidence != null) return confidence; } TransactionConfidence newConfidence = new TransactionConfidence(hash); table.put(hash, new WeakConfidenceReference(newConfidence, referenceQueue)); return newConfidence; } finally { lock.unlock(); } }