This commit is contained in:
chimp1984 2020-08-25 23:30:52 -05:00
parent c6c56b35f9
commit d59a3adbc3
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -81,6 +81,8 @@ public class Broadcaster implements BroadcastHandler.ResultHandler {
@Nullable NodeAddress sender,
@Nullable BroadcastHandler.Listener listener) {
broadcastRequests.add(new BroadcastRequest(message, sender, listener));
log.info("Broadcast requested for {}. We queue it up for next bundled broadcast.",
message.getClass().getSimpleName());
if (timer == null) {
timer = UserThread.runAfter(this::maybeBroadcastBundle, BROADCAST_INTERVAL_MS, TimeUnit.MILLISECONDS);
@ -89,9 +91,10 @@ public class Broadcaster implements BroadcastHandler.ResultHandler {
private void maybeBroadcastBundle() {
if (!broadcastRequests.isEmpty()) {
log.info("Broadcast bundled requests of {} messages", broadcastRequests.size());
BroadcastHandler broadcastHandler = new BroadcastHandler(networkNode, peerManager, this);
broadcastHandler.broadcast(new ArrayList<>(broadcastRequests));
broadcastHandlers.add(broadcastHandler);
broadcastHandler.broadcast(new ArrayList<>(broadcastRequests));
broadcastRequests.clear();
timer = null;