Skip to content

Commit

Permalink
don't override with unknown transaction confidences
Browse files Browse the repository at this point in the history
  • Loading branch information
jim618 committed Feb 19, 2016
1 parent 30452bc commit 1f217a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/main/java/org/bitcoinj/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -1159,13 +1159,20 @@ public TransactionConfidence getConfidence(Context context) {
public TransactionConfidence getConfidence(TxConfidenceTable table) {
TransactionConfidence confidenceInTable = table.getOrCreate(getHash());
if (confidence == null) {
// Use the confidence from the table as that is all we have
confidence = confidenceInTable;
} else {
// Check the confidence in the Context confidence table is the same object
if (System.identityHashCode(confidence) != System.identityHashCode(confidenceInTable)) {
log.debug("Confidence in tx has identity {} but the one in the confidence table is {}", System.identityHashCode(confidence), System.identityHashCode(confidenceInTable));
log.debug("Using the one in the confidence table");
confidence = confidenceInTable;

if (ConfidenceType.UNKNOWN.equals(confidenceInTable.getConfidenceType())) {
// Do not override an extant confidence if the confidenceType is Unknown
log.debug("Not overriding confidence as confidenceType is Unknown");
} else {
log.debug("Using the one in the confidence table");
confidence = confidenceInTable;
}
}
}
log.debug("TransactionConfidence for transaction with hash {} has identity {}", this.getHashAsString(), System.identityHashCode(confidence));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ private void readConfidence(Transaction tx, Protos.TransactionConfidence confide
confidenceType = ConfidenceType.UNKNOWN; break;
}
confidence.setConfidenceType(confidenceType);

if (confidenceProto.hasAppearedAtHeight()) {
if (confidence.getConfidenceType() != ConfidenceType.BUILDING) {
log.warn("Have appearedAtHeight but not BUILDING for tx {}", tx.getHashAsString());
Expand Down

0 comments on commit 1f217a9

Please sign in to comment.