From 1e6835f71dee050b372481d5ef86dc420e40240a Mon Sep 17 00:00:00 2001 From: romanman Date: Sun, 15 Jun 2014 15:43:37 +0100 Subject: [PATCH] BlockChain load NullPointerException resolved --- .../src/main/java/org/ethereum/core/Blockchain.java | 5 ++++- ethereumj-core/src/main/java/org/ethereum/core/Wallet.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java b/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java index e85fb122..666cdd35 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java @@ -172,7 +172,10 @@ public class Blockchain { logger.debug("Displaying blocks stored in DB sorted on blocknumber"); byte[] parentHash = Genesis.PARENT_HASH; // get Genesis block by parentHash for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) { - this.addBlock(new Block(db.get(parentHash))); + byte[] parentRLP = db.get(parentHash); + if (parentRLP == null) return; + + this.addBlock(new Block(parentRLP)); if (logger.isDebugEnabled()) logger.debug("Block: " + getLastBlock().getNumber() + " ---> " + getLastBlock().toFlatString()); parentHash = getLastBlock().getHash(); diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java index ab5261fd..77dff4d1 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java @@ -105,8 +105,9 @@ public class Wallet { public void processBlock(Block block){ - // todo: proceed coinbase when you are the miner that gets an award + if (block == null) return; + // todo: proceed coinbase when you are the miner that gets an award boolean walletUpdated = false; List transactions = block.getTransactionsList();