use of io.nuls.consensus.event.GetBlockHeaderEvent in project nuls by nuls-io.
the class GetBlockHeaderHandler method onEvent.
@Override
public void onEvent(GetBlockHeaderEvent event, String fromId) {
BlockHeader header;
if (null == event.getEventBody() || event.getEventBody().getHeight() == 0) {
header = blockService.getLocalBestBlock().getHeader();
} else {
Block block = blockService.getBlock(event.getEventBody().getHeight());
if (null == block) {
header = new BlockHeader();
header.setHeight(event.getEventBody().getHeight());
} else {
header = block.getHeader();
}
}
if (header == null) {
Log.error("header cannot be null");
return;
}
this.eventBroadcaster.sendToNode(new BlockHeaderEvent(header), fromId);
}
Aggregations