From cd10099d3f18585af1a08c86bf445917d9f071e5 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 2 May 2011 13:20:15 +0000 Subject: [PATCH] Some small renamings in BlockChain. Log but don't throw in TransactionOutput.isMine() if the script is unparseable. Suggestions from Miron. --- src/com/google/bitcoin/core/BlockChain.java | 10 +++++----- src/com/google/bitcoin/core/TransactionOutput.java | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/com/google/bitcoin/core/BlockChain.java b/src/com/google/bitcoin/core/BlockChain.java index 202e6f71..201c65a5 100644 --- a/src/com/google/bitcoin/core/BlockChain.java +++ b/src/com/google/bitcoin/core/BlockChain.java @@ -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 diff --git a/src/com/google/bitcoin/core/TransactionOutput.java b/src/com/google/bitcoin/core/TransactionOutput.java index 72455b94..daf001b9 100644 --- a/src/com/google/bitcoin/core/TransactionOutput.java +++ b/src/com/google/bitcoin/core/TransactionOutput.java @@ -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; } }