From 975dcbceaa9ef13cc28cb53ef344d4cefba76e7a Mon Sep 17 00:00:00 2001 From: nicksavers Date: Sat, 5 Jul 2014 23:14:13 +0200 Subject: [PATCH] Retrieve block from Blockchain index instead of DB --- .../src/main/java/org/ethereum/core/Blockchain.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 94bca447..91807205 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Blockchain.java @@ -85,8 +85,8 @@ public class Blockchain { } public Block getByNumber(long blockNr) { - return new Block(chainDb.get(ByteUtil.longToBytes(blockNr))); - } + return new Block(index.get(blockNr)); + } public void addBlocks(List blocks) { @@ -129,7 +129,7 @@ public class Blockchain { WorldManager.getInstance().applyBlock(block); this.chainDb.put(ByteUtil.longToBytes(block.getNumber()), block.getEncoded()); - this.index.put(block.getNumber(), block.getParentHash()); + this.index.put(block.getNumber(), block.getEncoded()); this.wallet.processBlock(block); this.updateGasPrice(block); @@ -200,7 +200,7 @@ public class Blockchain { logger.debug("Displaying blocks stored in DB sorted on blocknumber"); for (iterator.seekToFirst(); iterator.hasNext();) { this.lastBlock = new Block(iterator.next().getValue()); - this.index.put(lastBlock.getNumber(), lastBlock.getParentHash()); + this.index.put(lastBlock.getNumber(), lastBlock.getEncoded()); logger.debug("Block #{} -> {}", lastBlock.getNumber(), lastBlock.toFlatString()); } }