use of org.aion.zero.impl.sync.msg.BroadcastNewBlock in project aion by aionnetwork.
the class BlockPropagationHandler method send.
private boolean send(AionBlock block, int nodeId) {
// current proposal is to send to all peers with lower blockNumbers
AtomicBoolean sent = new AtomicBoolean();
this.p2pManager.getActiveNodes().values().stream().filter(n -> n.getIdHash() != nodeId).filter(n -> n.getBestBlockNumber() <= block.getNumber()).forEach(n -> {
if (log.isDebugEnabled())
log.debug("<sending-new-block hash=" + block.getShortHash() + " to-node=" + n.getIdShort() + ">");
this.p2pManager.send(n.getIdHash(), new BroadcastNewBlock(block));
sent.getAndSet(true);
});
return sent.get();
}
use of org.aion.zero.impl.sync.msg.BroadcastNewBlock in project aion by aionnetwork.
the class BlockPropagationHandler method propagateNewBlock.
// assumption here is that blocks propagated have unique hashes
public void propagateNewBlock(final AionBlock block) {
if (block == null)
return;
ByteArrayWrapper hashWrapped = new ByteArrayWrapper(block.getHash());
synchronized (this.cacheMap) {
this.cacheMap.put(hashWrapped, true);
}
this.p2pManager.getActiveNodes().values().forEach(n -> {
if (log.isDebugEnabled())
log.debug("<sending-new-block=" + block.getShortHash() + " to=" + n.getIdShort() + ">");
this.p2pManager.send(n.getIdHash(), new BroadcastNewBlock(block));
});
}
Aggregations