diff --git a/ethereumj-core/src/main/java/org/ethereum/listener/RecommendedGasPriceTracker.java b/ethereumj-core/src/main/java/org/ethereum/listener/RecommendedGasPriceTracker.java index b548941169..02f7b97a95 100644 --- a/ethereumj-core/src/main/java/org/ethereum/listener/RecommendedGasPriceTracker.java +++ b/ethereumj-core/src/main/java/org/ethereum/listener/RecommendedGasPriceTracker.java @@ -61,19 +61,20 @@ public void onBlock(BlockSummary blockSummary) { } private void onBlock(Block block) { - onTransactions(block.getTransactionsList()); - ++idx; - if (idx == getBlocksRecount()) { - Long newGasPrice = getGasPrice(); - if (newGasPrice != null) { - this.recommendedGasPrice = newGasPrice; + if (onTransactions(block.getTransactionsList())) { + ++idx; + if (idx == getBlocksRecount()) { + Long newGasPrice = getGasPrice(); + if (newGasPrice != null) { + this.recommendedGasPrice = newGasPrice; + } + idx = 0; } - idx = 0; } } - private synchronized void onTransactions(List txs) { - if (txs.isEmpty()) return; + private synchronized boolean onTransactions(List txs) { + if (txs.isEmpty()) return false; long[] gasPrices = new long[txs.size()]; for (int i = 0; i < txs.size(); ++i) { @@ -85,6 +86,7 @@ private synchronized void onTransactions(List txs) { blockGasPrices.remove(blockGasPrices.get(0)); } blockGasPrices.add(gasPrices); + return true; } private int calcGasPricesSize() {