Skip to content

Commit

Permalink
AbstractBlockChain: Print "Wallet/chain height mismatch" warning only…
Browse files Browse the repository at this point in the history
… if walletHeight > 0
  • Loading branch information
oscarguindzberg committed Dec 20, 2018
1 parent bdc84b5 commit fd3a526
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/bitcoinj/core/AbstractBlockChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ public final void addWallet(Wallet wallet) {
int walletHeight = wallet.getLastBlockSeenHeight();
int chainHeight = getBestChainHeight();
if (walletHeight != chainHeight) {
log.warn("Wallet/chain height mismatch: {} vs {}", walletHeight, chainHeight);
log.warn("Hashes: {} vs {}", wallet.getLastBlockSeenHash(), getChainHead().getHeader().getHash());

if(walletHeight > 0) {
log.warn("Wallet/chain height mismatch: {} vs {}", walletHeight, chainHeight);
log.warn("Hashes: {} vs {}", wallet.getLastBlockSeenHash(), getChainHead().getHeader().getHash());
}
// This special case happens when the VM crashes because of a transaction received. It causes the updated
// block store to persist, but not the wallet. In order to fix the issue, we roll back the block store to
// the wallet height to make it look like as if the block has never been received.
Expand Down

0 comments on commit fd3a526

Please sign in to comment.