mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 08:14:15 -05:00
Fix issue with not republishing data
This commit is contained in:
parent
485d0e8fd6
commit
a4b959df22
3 changed files with 19 additions and 8 deletions
|
|
@ -132,6 +132,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
|
|
||||||
// peer group
|
// peer group
|
||||||
peerGroup = new PeerGroup(networkNode);
|
peerGroup = new PeerGroup(networkNode);
|
||||||
|
peerGroup.setSeedNodeAddresses(seedNodeAddresses);
|
||||||
peerGroup.addAuthenticationListener(this);
|
peerGroup.addAuthenticationListener(this);
|
||||||
|
|
||||||
// P2P network data storage
|
// P2P network data storage
|
||||||
|
|
@ -274,7 +275,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
private void authenticateSeedNode() {
|
private void authenticateSeedNode() {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
checkNotNull(connectedSeedNode != null, "connectedSeedNode must not be null");
|
checkNotNull(connectedSeedNode != null, "connectedSeedNode must not be null");
|
||||||
peerGroup.authenticateToSeedNode(connectedSeedNode, seedNodeAddresses);
|
peerGroup.authenticateToSeedNode(connectedSeedNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
|
|
||||||
public static void setMaxConnectionsLowPriority(int maxConnectionsLowPriority) {
|
public static void setMaxConnectionsLowPriority(int maxConnectionsLowPriority) {
|
||||||
MAX_CONNECTIONS_LOW_PRIORITY = maxConnectionsLowPriority;
|
MAX_CONNECTIONS_LOW_PRIORITY = maxConnectionsLowPriority;
|
||||||
MAX_CONNECTIONS_NORMAL_PRIORITY = MAX_CONNECTIONS_LOW_PRIORITY + 4;
|
MAX_CONNECTIONS_NORMAL_PRIORITY = MAX_CONNECTIONS_LOW_PRIORITY + 6;
|
||||||
MAX_CONNECTIONS_HIGH_PRIORITY = MAX_CONNECTIONS_NORMAL_PRIORITY + 4;
|
MAX_CONNECTIONS_HIGH_PRIORITY = MAX_CONNECTIONS_NORMAL_PRIORITY + 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
@ -273,11 +273,16 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
// Authentication to seed node
|
// Authentication to seed node
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void authenticateToSeedNode(Address peerAddress, Set<Address> seedNodeAddresses) {
|
public void setSeedNodeAddresses(Set<Address> seedNodeAddresses) {
|
||||||
Log.traceCall();
|
|
||||||
seedNodeAddressesOptional = Optional.of(seedNodeAddresses);
|
seedNodeAddressesOptional = Optional.of(seedNodeAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void authenticateToSeedNode(Address peerAddress) {
|
||||||
|
Log.traceCall();
|
||||||
|
checkArgument(seedNodeAddressesOptional.isPresent(),
|
||||||
|
"seedNodeAddresses must be set before calling authenticateToSeedNode");
|
||||||
remainingSeedNodes.remove(peerAddress);
|
remainingSeedNodes.remove(peerAddress);
|
||||||
remainingSeedNodes.addAll(seedNodeAddresses);
|
remainingSeedNodes.addAll(seedNodeAddressesOptional.get());
|
||||||
authenticateToFirstSeedNode(peerAddress);
|
authenticateToFirstSeedNode(peerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -797,7 +802,6 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<ReportedPeer> getAndRemoveNotAuthenticatingReportedPeer() {
|
private Optional<ReportedPeer> getAndRemoveNotAuthenticatingReportedPeer() {
|
||||||
Log.traceCall();
|
|
||||||
Optional<ReportedPeer> reportedPeer = Optional.empty();
|
Optional<ReportedPeer> reportedPeer = Optional.empty();
|
||||||
List<ReportedPeer> list = new ArrayList<>(reportedPeers);
|
List<ReportedPeer> list = new ArrayList<>(reportedPeers);
|
||||||
authenticationHandshakes.keySet().stream().forEach(e -> list.remove(new ReportedPeer(e)));
|
authenticationHandshakes.keySet().stream().forEach(e -> list.remove(new ReportedPeer(e)));
|
||||||
|
|
@ -815,7 +819,6 @@ public class PeerGroup implements MessageListener, ConnectionListener {
|
||||||
|
|
||||||
|
|
||||||
private Optional<Address> getAndRemoveNotAuthenticatingSeedNode() {
|
private Optional<Address> getAndRemoveNotAuthenticatingSeedNode() {
|
||||||
Log.traceCall();
|
|
||||||
Optional<Address> seedNode = Optional.empty();
|
Optional<Address> seedNode = Optional.empty();
|
||||||
authenticationHandshakes.keySet().stream().forEach(e -> remainingSeedNodes.remove(e));
|
authenticationHandshakes.keySet().stream().forEach(e -> remainingSeedNodes.remove(e));
|
||||||
authenticatedPeers.keySet().stream().forEach(e -> remainingSeedNodes.remove(e));
|
authenticatedPeers.keySet().stream().forEach(e -> remainingSeedNodes.remove(e));
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,13 @@ public class P2PDataStorage implements MessageListener {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
map.put(hashOfPayload, protectedData);
|
map.put(hashOfPayload, protectedData);
|
||||||
|
|
||||||
|
// Republished data have a larger sequence number. We set the rePublish flag to enable broadcasting
|
||||||
|
// even we had the data with the old seq nr. already
|
||||||
|
if (sequenceNumberMap.containsKey(hashOfPayload) &&
|
||||||
|
protectedData.sequenceNumber > sequenceNumberMap.get(hashOfPayload))
|
||||||
|
rePublish = true;
|
||||||
|
|
||||||
sequenceNumberMap.put(hashOfPayload, protectedData.sequenceNumber);
|
sequenceNumberMap.put(hashOfPayload, protectedData.sequenceNumber);
|
||||||
storage.queueUpForSave(sequenceNumberMap);
|
storage.queueUpForSave(sequenceNumberMap);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue