EthereumListener update
This commit is contained in:
parent
628be155e1
commit
cbb556c1a9
|
@ -147,6 +147,20 @@ public class Blockchain {
|
|||
if (listener != null)
|
||||
listener.trace(String.format("Block chain size: [ %d ]", this.getSize()));
|
||||
|
||||
EthereumListener ethereumListener = WorldManager.getInstance().getListener();
|
||||
if (ethereumListener != null)
|
||||
ethereumListener.onBlock(block);
|
||||
|
||||
/*
|
||||
if (lastBlock.getNumber() >= 30) {
|
||||
System.out.println("** checkpoint **");
|
||||
|
||||
this.close();
|
||||
WorldManager.getInstance().getRepository().close();
|
||||
System.exit(1);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public void processBlock(Block block) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.ethereum.listener;
|
||||
|
||||
import org.ethereum.core.Block;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
*
|
||||
|
@ -10,4 +12,5 @@ package org.ethereum.listener;
|
|||
public interface EthereumListener {
|
||||
|
||||
public void trace(String output);
|
||||
public void onBlock(Block block);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
|
||||
logger.info("Send: " + StaticMessages.HELLO_MESSAGE.toString());
|
||||
msgQueue.sendMessage(StaticMessages.HELLO_MESSAGE);
|
||||
sendPing();
|
||||
|
||||
// sample for pinging in background
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
|
@ -249,6 +250,8 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
RLPList rlpList = RLP.decode2(payload);
|
||||
GetChainMessage getChainMessage = new GetChainMessage(rlpList);
|
||||
|
||||
|
||||
|
||||
logger.info(getChainMessage.toString());
|
||||
if (peerListener != null) peerListener.console(getChainMessage.toString());
|
||||
}
|
||||
|
@ -323,6 +326,7 @@ public class EthereumProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
SystemProperties.CONFIG.maxBlocksQueued()) return;
|
||||
|
||||
Block lastBlock = WorldManager.getInstance().getBlockchain().getBlockQueue().getLast();
|
||||
if (lastBlock == null) return;
|
||||
|
||||
byte[] hash = lastBlock.getHash();
|
||||
GetChainMessage chainMessage =
|
||||
|
|
Loading…
Reference in New Issue