Search in sources :

Example 1 with GetBlockMessage

use of co.rsk.net.messages.GetBlockMessage in project rskj by rsksmart.

the class BlockSyncService method requestMissingHash.

private void requestMissingHash(MessageChannel sender, Keccak256 hash) {
    if (sender == null) {
        return;
    }
    unknownBlockHashes.put(hash, 1);
    logger.trace("Missing block {}", hash.toString().substring(0, 10));
    sender.sendMessage(new GetBlockMessage(hash.getBytes()));
}
Also used : GetBlockMessage(co.rsk.net.messages.GetBlockMessage)

Example 2 with GetBlockMessage

use of co.rsk.net.messages.GetBlockMessage in project rskj by rsksmart.

the class RskWireProtocol method channelRead0.

@Override
public void channelRead0(final ChannelHandlerContext ctx, EthMessage msg) throws InterruptedException {
    super.channelRead0(ctx, msg);
    if (this.messageRecorder != null) {
        this.messageRecorder.recordMessage(messageSender.getPeerNodeID(), msg);
    }
    if (!hasGoodReputation(ctx)) {
        ctx.disconnect();
        return;
    }
    Metrics.messageBytes(messageSender.getPeerNodeID(), msg.getEncoded().length);
    switch(msg.getCommand()) {
        case STATUS:
            processStatus((org.ethereum.net.eth.message.StatusMessage) msg, ctx);
            break;
        case RSK_MESSAGE:
            RskMessage rskmessage = (RskMessage) msg;
            Message message = rskmessage.getMessage();
            switch(message.getMessageType()) {
                case BLOCK_MESSAGE:
                    loggerNet.trace("RSK Block Message: Block {} {} from {}", ((BlockMessage) message).getBlock().getNumber(), ((BlockMessage) message).getBlock().getShortHash(), this.messageSender.getPeerNodeID());
                    syncStats.addBlocks(1);
                    break;
                case GET_BLOCK_MESSAGE:
                    loggerNet.trace("RSK Get Block Message: Block {} from {}", Hex.toHexString(((GetBlockMessage) message).getBlockHash()).substring(0, 10), this.messageSender.getPeerNodeID());
                    syncStats.getBlock();
                    break;
                case STATUS_MESSAGE:
                    loggerNet.trace("RSK Status Message: Block {} {} from {}", ((StatusMessage) message).getStatus().getBestBlockNumber(), Hex.toHexString(((StatusMessage) message).getStatus().getBestBlockHash()).substring(0, 10), this.messageSender.getPeerNodeID());
                    syncStats.addStatus();
                    break;
            }
            if (this.messageHandler != null) {
                this.messageHandler.postMessage(this.messageSender, rskmessage.getMessage());
            }
            break;
        default:
            break;
    }
}
Also used : BlockMessage(co.rsk.net.messages.BlockMessage) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) StatusMessage(co.rsk.net.messages.StatusMessage) Message(co.rsk.net.messages.Message) BlockMessage(co.rsk.net.messages.BlockMessage) EthMessage(org.ethereum.net.eth.message.EthMessage) GetBlockMessage(co.rsk.net.messages.GetBlockMessage) TransactionsMessage(org.ethereum.net.eth.message.TransactionsMessage) co.rsk.net(co.rsk.net) StatusMessage(co.rsk.net.messages.StatusMessage)

Example 3 with GetBlockMessage

use of co.rsk.net.messages.GetBlockMessage in project rskj by rsksmart.

the class WriterMessageRecorderTest method createRskMessage.

public static Message createRskMessage() {
    Block block = new BlockGenerator().getBlock(1);
    GetBlockMessage message = new GetBlockMessage(block.getHash().getBytes());
    return new RskMessage(config, message);
}
Also used : GetBlockMessage(co.rsk.net.messages.GetBlockMessage) Block(org.ethereum.core.Block) BlockGenerator(co.rsk.blockchain.utils.BlockGenerator)

Aggregations

GetBlockMessage (co.rsk.net.messages.GetBlockMessage)3 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)1 co.rsk.net (co.rsk.net)1 BlockMessage (co.rsk.net.messages.BlockMessage)1 Message (co.rsk.net.messages.Message)1 StatusMessage (co.rsk.net.messages.StatusMessage)1 Block (org.ethereum.core.Block)1 EthMessage (org.ethereum.net.eth.message.EthMessage)1 TransactionsMessage (org.ethereum.net.eth.message.TransactionsMessage)1