use of io.nuls.kernel.model.Result in project nuls by nuls-io.
the class GetBlocksHashHandler method sendNotFound.
private void sendNotFound(Node node, NulsDigestData hash) {
NotFoundMessage event = new NotFoundMessage();
NotFound data = new NotFound(MessageDataType.HASHES, hash);
event.setMsgBody(data);
Result result = this.messageBusService.sendToNode(event, node, true);
if (result.isFailed()) {
Log.warn("send not found failed:" + node.getId() + ", hash:" + hash);
}
}
use of io.nuls.kernel.model.Result in project nuls by nuls-io.
the class ForwardSmallBlockHandler method onMessage.
@Override
public void onMessage(ForwardSmallBlockMessage message, Node fromNode) {
if (message == null || fromNode == null || !fromNode.isHandShake() || null == message.getMsgBody()) {
return;
}
NulsDigestData hash = message.getMsgBody();
if (!SmallBlockDuplicateRemoval.needDownloadSmallBlock(hash)) {
return;
}
GetSmallBlockMessage getSmallBlockMessage = new GetSmallBlockMessage();
getSmallBlockMessage.setMsgBody(hash);
Result result = messageBusService.sendToNode(getSmallBlockMessage, fromNode, true);
// if (result.isFailed()) {
// SmallBlockDuplicateRemoval.removeForward(hash);
// return;
// }
}
use of io.nuls.kernel.model.Result in project nuls by nuls-io.
the class GetBlockHandler method sendNotFound.
private void sendNotFound(NulsDigestData hash, Node node) {
NotFoundMessage message = new NotFoundMessage();
NotFound data = new NotFound(MessageDataType.BLOCK, hash);
message.setMsgBody(data);
Result result = this.messageBusService.sendToNode(message, node, true);
if (result.isFailed()) {
Log.warn("send BLOCK NotFound failed:" + node.getId() + ", hash:" + hash);
}
}
use of io.nuls.kernel.model.Result in project nuls by nuls-io.
the class GetBlocksByHeightHandler method sendNotFound.
private void sendNotFound(NulsDigestData hash, Node node) {
NotFoundMessage message = new NotFoundMessage();
NotFound data = new NotFound(MessageDataType.BLOCKS, hash);
message.setMsgBody(data);
Result result = this.messageBusService.sendToNode(message, node, true);
if (result.isFailed()) {
Log.warn("send BLOCK NotFound failed:" + node.getId() + ", hash:" + hash);
}
}
use of io.nuls.kernel.model.Result in project nuls by nuls-io.
the class GetSmallBlockHandler method onMessage.
@Override
public void onMessage(GetSmallBlockMessage message, Node fromNode) {
if (message == null || fromNode == null || null == message.getMsgBody()) {
return;
}
NulsDigestData blockHash = message.getMsgBody();
SmallBlock smallBlock = cacheManager.getSmallBlockByHash(blockHash);
if (null == smallBlock) {
return;
}
SmallBlockMessage smallBlockMessage = new SmallBlockMessage();
smallBlockMessage.setMsgBody(smallBlock);
Result result = messageBusService.sendToNode(smallBlockMessage, fromNode, true);
if (!result.isSuccess()) {
Log.error("---send smallBlockMessage fail, height:" + smallBlock.getHeader().getHeight() + "hash: " + smallBlock.getHeader().getHash().getDigestHex());
Log.error("----" + result.getMsg());
}
}
Aggregations