Some small renamings in BlockChain. Log but don't throw in TransactionOutput.isMine() if the script is unparseable. Suggestions from Miron.

This commit is contained in:
Mike Hearn
2011-05-02 13:20:15 +00:00
parent 62302611f6
commit cd10099d3f
2 changed files with 11 additions and 6 deletions

View File

@@ -163,8 +163,8 @@ public class BlockChain {
//
// Note that we send the transactions to the wallet FIRST, even if we're about to re-organize this block
// to become the new best chain head. This simplifies handling of the re-org in the Wallet class.
boolean causedSplit = newStoredBlock.moreWorkThan(chainHead);
if (causedSplit) {
boolean haveNewBestChain = newStoredBlock.moreWorkThan(chainHead);
if (haveNewBestChain) {
log.info("Block is causing a re-organize");
} else {
log.info("Block forks the chain, but it did not cause a reorganize.");
@@ -176,15 +176,15 @@ public class BlockChain {
sendTransactionsToWallet(newStoredBlock, NewBlockType.SIDE_CHAIN, newTransactions);
}
if (causedSplit)
handleChainSplit(newStoredBlock);
if (haveNewBestChain)
handleNewBestChain(newStoredBlock);
}
}
/**
* Called as part of connecting a block when the new block results in a different chain having higher total work.
*/
private void handleChainSplit(StoredBlock newChainHead) throws BlockStoreException, VerificationException {
private void handleNewBestChain(StoredBlock newChainHead) throws BlockStoreException, VerificationException {
// This chain has overtaken the one we currently believe is best. Reorganize is required.
//
// Firstly, calculate the block at which the chain diverged. We only need to examine the

View File

@@ -16,6 +16,9 @@
package com.google.bitcoin.core;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
@@ -26,6 +29,7 @@ import java.math.BigInteger;
* of the Transaction message.
*/
public class TransactionOutput extends Message implements Serializable {
private static final Logger log = LoggerFactory.getLogger(TransactionOutput.class);
private static final long serialVersionUID = -590332479859256824L;
// A transaction output has some value and a script used for authenticating that the redeemer is allowed to spend
@@ -114,7 +118,8 @@ public class TransactionOutput extends Message implements Serializable {
byte[] pubkeyHash = getScriptPubKey().getPubKeyHash();
return wallet.isPubKeyHashMine(pubkeyHash);
} catch (ScriptException e) {
throw new RuntimeException(e);
log.error("Could not parse tx output script: {}", e.toString());
return false;
}
}