Search in sources :

Example 1 with BlockIdentifier

use of org.aion.mcf.types.BlockIdentifier in project aion by aionnetwork.

the class ReqBlocksHeadersHandler method receive.

@Override
public void receive(int _nodeIdHashcode, String _displayId, final byte[] _msgBytes) {
    ReqBlocksHeaders reqHeaders = ReqBlocksHeaders.decode(_msgBytes);
    if (reqHeaders != null) {
        long fromBlock = reqHeaders.getFromBlock();
        int take = reqHeaders.getTake();
        this.log.debug("<req-headers from-number={} size={} node={}>", fromBlock, take, _displayId);
        List<A0BlockHeader> headers = this.blockchain.getListOfHeadersStartFrom(new BlockIdentifier(null, fromBlock), 0, Math.min(take, max), false);
        ResBlocksHeaders rbhs = new ResBlocksHeaders(headers);
        this.p2pMgr.send(_nodeIdHashcode, rbhs);
    } else
        this.log.error("<req-headers decode-msg msg-bytes={} node={}>", _msgBytes == null ? 0 : _msgBytes.length, _nodeIdHashcode);
}
Also used : BlockIdentifier(org.aion.mcf.types.BlockIdentifier) A0BlockHeader(org.aion.zero.types.A0BlockHeader) ResBlocksHeaders(org.aion.zero.impl.sync.msg.ResBlocksHeaders) ReqBlocksHeaders(org.aion.zero.impl.sync.msg.ReqBlocksHeaders)

Aggregations

BlockIdentifier (org.aion.mcf.types.BlockIdentifier)1 ReqBlocksHeaders (org.aion.zero.impl.sync.msg.ReqBlocksHeaders)1 ResBlocksHeaders (org.aion.zero.impl.sync.msg.ResBlocksHeaders)1 A0BlockHeader (org.aion.zero.types.A0BlockHeader)1