Search in sources :

Example 6 with RskMessage

use of co.rsk.net.eth.RskMessage in project rskj by rsksmart.

the class ChannelManagerImpl method broadcastTransactionMessage.

/**
 * Propagates the transactions message across active peers with exclusion of
 * 'receivedFrom' peer.
 *
 * @param tx           transactions to be sent
 * @param receivedFrom the peer which sent original message or null if
 *                     the transactions were originated by this peer
 */
public void broadcastTransactionMessage(List<Transaction> tx, Channel receivedFrom) {
    tx.forEach(Metrics::broadcastTransaction);
    synchronized (activePeers) {
        TransactionsMessage txsmsg = new TransactionsMessage(tx);
        EthMessage msg = new RskMessage(config, txsmsg);
        for (Channel channel : activePeers.values()) {
            if (channel != receivedFrom) {
                channel.sendMessage(msg);
            }
        }
    }
}
Also used : Metrics(co.rsk.net.Metrics) EthMessage(org.ethereum.net.eth.message.EthMessage) RskMessage(co.rsk.net.eth.RskMessage)

Aggregations

RskMessage (co.rsk.net.eth.RskMessage)6 EthMessage (org.ethereum.net.eth.message.EthMessage)6 Metrics (co.rsk.net.Metrics)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 RskSystemProperties (co.rsk.config.RskSystemProperties)3 NodeID (co.rsk.net.NodeID)3 Status (co.rsk.net.Status)3 co.rsk.net.messages (co.rsk.net.messages)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 InetAddress (java.net.InetAddress)3 java.util (java.util)3 Executors (java.util.concurrent.Executors)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)3 TimeUnit (java.util.concurrent.TimeUnit)3 Collectors (java.util.stream.Collectors)3 Nonnull (javax.annotation.Nonnull)3 Nullable (javax.annotation.Nullable)3 CollectionUtils (org.apache.commons.collections4.CollectionUtils)3 LRUMap (org.apache.commons.collections4.map.LRUMap)3 NodeFilter (org.ethereum.config.NodeFilter)3