Search in sources :

Example 1 with InventoryType

use of org.tron.protos.Protocol.Inventory.InventoryType in project java-tron by tronprotocol.

the class NodeImpl method broadcast.

/**
 * broadcast msg.
 *
 * @param msg msg to bradcast
 */
public void broadcast(Message msg) {
    InventoryType type;
    if (msg instanceof BlockMessage) {
        logger.info("Ready to broadcast a block, Its hash is " + msg.getMessageId());
        freshBlockId.offer(((BlockMessage) msg).getBlockId());
        blockToAdvertise.add(((BlockMessage) msg).getBlockId());
        type = InventoryType.BLOCK;
    } else if (msg instanceof TransactionMessage) {
        trxToAdvertise.add(msg.getMessageId());
        type = InventoryType.TRX;
    } else {
        return;
    }
    // TODO: here need to cache fresh message to let peer fetch these data not from DB
    advObjToSpread.put(msg.getMessageId(), type);
}
Also used : BlockMessage(org.tron.core.net.message.BlockMessage) TransactionMessage(org.tron.core.net.message.TransactionMessage) InventoryType(org.tron.protos.Protocol.Inventory.InventoryType)

Aggregations

BlockMessage (org.tron.core.net.message.BlockMessage)1 TransactionMessage (org.tron.core.net.message.TransactionMessage)1 InventoryType (org.tron.protos.Protocol.Inventory.InventoryType)1