Search in sources :

Example 6 with Result

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);
    }
}
Also used : NotFoundMessage(io.nuls.protocol.message.NotFoundMessage) NotFound(io.nuls.protocol.model.NotFound) Result(io.nuls.kernel.model.Result)

Example 7 with Result

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;
// }
}
Also used : NulsDigestData(io.nuls.kernel.model.NulsDigestData) GetSmallBlockMessage(io.nuls.protocol.message.GetSmallBlockMessage) Result(io.nuls.kernel.model.Result)

Example 8 with Result

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);
    }
}
Also used : NotFoundMessage(io.nuls.protocol.message.NotFoundMessage) NotFound(io.nuls.protocol.model.NotFound) Result(io.nuls.kernel.model.Result)

Example 9 with Result

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);
    }
}
Also used : NotFound(io.nuls.protocol.model.NotFound) Result(io.nuls.kernel.model.Result)

Example 10 with Result

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());
    }
}
Also used : SmallBlock(io.nuls.protocol.model.SmallBlock) NulsDigestData(io.nuls.kernel.model.NulsDigestData) Result(io.nuls.kernel.model.Result)

Aggregations

Result (io.nuls.kernel.model.Result)70 NulsException (io.nuls.kernel.exception.NulsException)16 IOException (java.io.IOException)15 NulsRuntimeException (io.nuls.kernel.exception.NulsRuntimeException)12 ValidateResult (io.nuls.kernel.validate.ValidateResult)11 AccountPo (io.nuls.account.storage.po.AccountPo)7 RpcClientResult (io.nuls.kernel.model.RpcClientResult)7 ArrayList (java.util.ArrayList)7 Account (io.nuls.account.model.Account)6 NulsDigestData (io.nuls.kernel.model.NulsDigestData)5 Test (org.junit.Test)5 CryptoException (io.nuls.core.tools.crypto.Exception.CryptoException)4 BatchOperation (io.nuls.db.service.BatchOperation)4 Address (io.nuls.kernel.model.Address)4 Block (io.nuls.kernel.model.Block)4 BlockHeader (io.nuls.kernel.model.BlockHeader)4 Transaction (io.nuls.kernel.model.Transaction)4 Node (io.nuls.network.model.Node)4 NotFound (io.nuls.protocol.model.NotFound)4 ApiOperation (io.swagger.annotations.ApiOperation)4