Search in sources :

Example 1 with SyncBlockChainMessage

use of org.tron.core.net.message.SyncBlockChainMessage in project java-tron by tronprotocol.

the class NodeImpl method syncNextBatchChainIds.

private void syncNextBatchChainIds(PeerConnection peer) {
    try {
        Deque<BlockId> chainSummary = del.getBlockChainSummary(peer.getHeadBlockWeBothHave(), ((LinkedList<BlockId>) peer.getSyncBlockToFetch()));
        peer.setSyncChainRequested(new Pair<>((LinkedList<BlockId>) chainSummary, System.currentTimeMillis()));
        peer.sendMessage(new SyncBlockChainMessage((LinkedList<BlockId>) chainSummary));
    } catch (Exception e) {
        // TODO: use tron excpetion here
        logger.debug(e.getMessage(), e);
        // TODO: unlink?
        disconnectPeer(peer, ReasonCode.BAD_PROTOCOL);
    }
}
Also used : SyncBlockChainMessage(org.tron.core.net.message.SyncBlockChainMessage) BlockId(org.tron.core.capsule.BlockCapsule.BlockId) LinkedList(java.util.LinkedList) UnReachBlockException(org.tron.core.exception.UnReachBlockException) TronException(org.tron.core.exception.TronException) BadTransactionException(org.tron.core.exception.BadTransactionException) BadBlockException(org.tron.core.exception.BadBlockException) TraitorPeerException(org.tron.core.exception.TraitorPeerException) UnLinkedBlockException(org.tron.core.exception.UnLinkedBlockException)

Aggregations

LinkedList (java.util.LinkedList)1 BlockId (org.tron.core.capsule.BlockCapsule.BlockId)1 BadBlockException (org.tron.core.exception.BadBlockException)1 BadTransactionException (org.tron.core.exception.BadTransactionException)1 TraitorPeerException (org.tron.core.exception.TraitorPeerException)1 TronException (org.tron.core.exception.TronException)1 UnLinkedBlockException (org.tron.core.exception.UnLinkedBlockException)1 UnReachBlockException (org.tron.core.exception.UnReachBlockException)1 SyncBlockChainMessage (org.tron.core.net.message.SyncBlockChainMessage)1