Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
minor mod
Browse files Browse the repository at this point in the history
  • Loading branch information
smatthewenglish committed Nov 26, 2018
1 parent 1cc68ef commit 38a1f53
Show file tree
Hide file tree
Showing 2 changed files with 340 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class RecursivePeerRefreshState {
private final int CONCURRENT_REQUEST_LIMIT = 3;
private final BytesValue target;
private final PeerBlacklist peerBlacklist;
private BondingAgent bondingAgent;
private NeighborFinder neighborFinder;
private HashMap<Peer, Integer> anteMap;
private final BondingAgent bondingAgent;
private final NeighborFinder neighborFinder;
private final HashMap<Peer, Integer> anteMap;
private SortedSet<Map.Entry<Peer, Integer>> distanceSortedPeers;
// List<OutstandingRequest> outstandingRequestList;
private List<BytesValue> outstandingRequestList;
List<OutstandingRequest> outstandingRequestList;
// private List<BytesValue> outstandingRequestList;
private List<BytesValue> contactedInCurrentExecution;

RecursivePeerRefreshState(
Expand Down Expand Up @@ -68,12 +68,12 @@ HashMap<Peer, Integer> getAnteMap() {
return anteMap;
}

List<BytesValue> getOutstandingRequestList() {
List<OutstandingRequest> getOutstandingRequestList() {
return outstandingRequestList;
}

void addToOutstandingRequests(final BytesValue id) {
outstandingRequestList.add(id);
outstandingRequestList.add(new OutstandingRequest(id));
}

private void performIteration() {
Expand Down Expand Up @@ -101,7 +101,7 @@ private void initiatePeerRefreshCycle(final List<Peer> peers) {
if (!contactedInCurrentExecution.contains(peer.getId())) {
// Save the name of this peer, so we know when it responds to us
BytesValue peerId = peer.getId();
outstandingRequestList.add(peerId);
outstandingRequestList.add(new OutstandingRequest(peerId));
contactedInCurrentExecution.add(peerId);
neighborFinder.issueFindNodeRequest(peer);
}
Expand All @@ -128,7 +128,7 @@ private List<Peer> determineFindNodeCandidates() {
/** Process a received packet, add the contents, i.e. new peers, to the 'anteMap'. */
void digestNeighboursPacket(
final NeighborsPacketData neighboursPacket, final BytesValue peerIdentifier) {
if (outstandingRequestList.contains(peerIdentifier)) {
if (outstandingRequestList.contains(new OutstandingRequest(peerIdentifier))) {
// Get the peers from this packet...
List<Peer> receivedPeerList = neighboursPacket.getNodes();
// Treat each one of them individually...
Expand All @@ -141,7 +141,7 @@ void digestNeighboursPacket(
}
}
// We are no longer waiting on this peer's return message
outstandingRequestList.remove(peerIdentifier);
outstandingRequestList.remove(new OutstandingRequest(peerIdentifier));
performIteration();
}
// If we received a neighbours packet from a peer from whom
Expand All @@ -168,7 +168,7 @@ public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OutstandingRequest that = (OutstandingRequest) o;
return Objects.equals(peerId, that.peerId);
return peerId.equals(that.peerId);
}

@Override
Expand Down
Loading

0 comments on commit 38a1f53

Please sign in to comment.