use of io.nuls.consensus.entity.GetSmallBlockParam in project nuls by nuls-io.
the class DownloadDataUtils method requestSmallBlock.
public void requestSmallBlock(NulsDigestData blockHash, String nodeId) {
GetSmallBlockRequest request = new GetSmallBlockRequest();
GetSmallBlockParam param = new GetSmallBlockParam();
param.setBlockHash(blockHash);
request.setEventBody(param);
smbRequest.put(blockHash.getDigestHex(), System.currentTimeMillis());
Integer value = smbRequestCount.get(blockHash.getDigestHex());
if (value == null) {
value = 0;
}
smbRequestCount.put(blockHash.getDigestHex(), 1 + value);
if (StringUtils.isBlank(nodeId)) {
eventBroadcaster.broadcastAndCache(request, false);
} else {
eventBroadcaster.sendToNode(request, nodeId);
}
}
use of io.nuls.consensus.entity.GetSmallBlockParam in project nuls by nuls-io.
the class BlockHeaderHandler method onEvent.
@Override
public void onEvent(BlockHeaderEvent event, String fromId) {
BlockHeader header = event.getEventBody();
if (null == header) {
Log.warn("recieved a null blockHeader!");
return;
}
Block block = blockManager.getBlock(header.getHash().getDigestHex());
if (null != block) {
return;
}
GetSmallBlockRequest request = new GetSmallBlockRequest();
GetSmallBlockParam param = new GetSmallBlockParam();
param.setBlockHash(header.getHash());
request.setEventBody(param);
eventBroadcaster.sendToNode(request, fromId);
temporaryCacheManager.cacheBlockHeader(header);
}
Aggregations