Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

send heartbeat pulses and request tx using heartbeat #1830

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

acha-bill
Copy link
Contributor

@acha-bill acha-bill commented Apr 8, 2020

Description

Adds a new thread that sends heartbeat messages to neighbours every minute.
Then it requests txs only from neighbours who have the tx by checking their first and last solid milestone index from the heartbeat.
If the neighbour does not support protocol v2 yet, we request from it anyways.

Fixes #1798

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How Has This Been Tested?

Add unit tests that check that txs are broadcasted only from neighbors according to their heartbeat.

Checklist:

  • My code follows the style guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -22,6 +22,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import com.iota.iri.network.NeighborRouter;
import com.iota.iri.network.TipsRequester;
import com.iota.iri.network.TransactionRequester;
import com.iota.iri.network.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private final SilentScheduledExecutorService executorService = new DedicatedScheduledExecutorService(
"Heartbeat Pulse");

public HeartbeatPulseImpl(NeighborRouter neighborRouter, SnapshotProvider snapshotProvider) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acha-bill acha-bill changed the title [DRAFT] send heartbeat pulses and request tx using heartbeat send heartbeat pulses and request tx using heartbeat Apr 14, 2020
int max = 0;
for (PruningCondition condition: pruningConditions) {
if(condition.getSnapshotPruningMilestone() > max){
max = condition.getSnapshotPruningMilestone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the smallest milestone no? As we only prune the one that is lowest possible (to prevent pruning too much)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Yes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use neighbors according to heartbeat
3 participants