mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-02-11 03:06:26 +00:00
Adding block receipts to listener cycles
This commit is contained in:
parent
277ca6af7a
commit
0e2720894b
@ -216,7 +216,7 @@ public class BlockchainImpl implements Blockchain {
|
||||
AdvancedDeviceUtils.adjustDetailedTracing(block.getNumber());
|
||||
}
|
||||
|
||||
processBlock(block);
|
||||
List<TransactionReceipt> receipts = processBlock(block);
|
||||
stateLogger.info("applied reward for block: [{}] \n state: [{}]",
|
||||
block.getNumber(),
|
||||
Hex.toHexString(repository.getRoot()));
|
||||
@ -233,6 +233,7 @@ public class BlockchainImpl implements Blockchain {
|
||||
|
||||
listener.trace(String.format("Block chain size: [ %d ]", this.getSize()));
|
||||
listener.onBlock(block);
|
||||
listener.onBlockReciepts(receipts);
|
||||
|
||||
if (blockQueue.size() == 0 &&
|
||||
!syncDoneCalled &&
|
||||
@ -305,7 +306,7 @@ public class BlockchainImpl implements Blockchain {
|
||||
|
||||
}
|
||||
|
||||
private void processBlock(Block block) {
|
||||
private List<TransactionReceipt> processBlock(Block block) {
|
||||
|
||||
List<TransactionReceipt> receipts = new ArrayList<>();
|
||||
if (isValid(block)) {
|
||||
@ -320,6 +321,8 @@ public class BlockchainImpl implements Blockchain {
|
||||
} else {
|
||||
logger.warn("Invalid block with nr: {}", block.getNumber());
|
||||
}
|
||||
|
||||
return receipts;
|
||||
}
|
||||
|
||||
private List<TransactionReceipt> applyBlock(Block block) {
|
||||
@ -400,7 +403,7 @@ public class BlockchainImpl implements Blockchain {
|
||||
String worldStateRootHash = Hex.toHexString(repository.getRoot());
|
||||
if (!blockStateRootHash.equals(worldStateRootHash)) {
|
||||
|
||||
stateLogger.info("BLOCK: STATE CONFLICT! block: {} worldstate {} mismatch", block.getNumber(), worldStateRootHash);
|
||||
stateLogger.error("BLOCK: STATE CONFLICT! block: {} worldstate {} mismatch", block.getNumber(), worldStateRootHash);
|
||||
adminInfo.lostConsensus();
|
||||
|
||||
// in case of rollback hard move the root
|
||||
|
@ -2,6 +2,7 @@ package org.ethereum.listener;
|
||||
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.core.TransactionReceipt;
|
||||
import org.ethereum.net.message.Message;
|
||||
import org.ethereum.net.p2p.HelloMessage;
|
||||
|
||||
@ -33,6 +34,11 @@ public class CompositeEthereumListener implements EthereumListener {
|
||||
listener.onBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockReciepts(List<TransactionReceipt> receipts) {
|
||||
for (EthereumListener listener : listeners)
|
||||
listener.onBlockReciepts(receipts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecvMessage(Message message) {
|
||||
@ -80,4 +86,6 @@ public class CompositeEthereumListener implements EthereumListener {
|
||||
public void addListener(EthereumListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package org.ethereum.listener;
|
||||
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.core.TransactionReceipt;
|
||||
import org.ethereum.net.message.Message;
|
||||
import org.ethereum.net.p2p.HelloMessage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -17,6 +19,8 @@ public interface EthereumListener {
|
||||
|
||||
public void onBlock(Block block);
|
||||
|
||||
public void onBlockReciepts(List<TransactionReceipt> receipts);
|
||||
|
||||
public void onRecvMessage(Message message);
|
||||
|
||||
public void onSendMessage(Message message);
|
||||
|
@ -2,9 +2,11 @@ package org.ethereum.listener;
|
||||
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.core.TransactionReceipt;
|
||||
import org.ethereum.net.message.Message;
|
||||
import org.ethereum.net.p2p.HelloMessage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -51,4 +53,9 @@ public class EthereumListenerAdapter implements EthereumListener {
|
||||
public void onNoConnections() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockReciepts(List<TransactionReceipt> receipts) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,6 @@ public class WorldManager {
|
||||
Hex.toHexString(blockchain.getBestBlock().getStateRoot()));
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG.rootHashStart() != null) {
|
||||
|
||||
// update world state by dummy hash
|
||||
|
@ -89,7 +89,7 @@ public class BlockQueue {
|
||||
blockchain.tryToConnect(block);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error: ", e.getMessage());
|
||||
logger.error("Error: {} ", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user