Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PeerFinder: #615

Closed
wants to merge 34 commits into from
Closed

Conversation

vinniefalco
Copy link
Contributor

Previously, the PeerFinder manager constructed with a Callback object provided by the owner which was used to perform operations like connecting, disconnecting, and sending messages. This made it difficult to change the overlay code because a single call into the PeerFinder could cause both OverlayImpl and PeerImp to be re-entered one or more times, sometimes while holding a recursive mutex. This change eliminates the callback by changing PeerFinder functions to return values indicating the action the caller should take.

As a result of this change the PeerFinder no longer needs its own dedicated thread. OverlayImpl is changed to call into PeerFinder on a timer to perform periodic activities. Furthermore the Checker class used to perform connectivity checks has been refactored. It no longer uses an abstract base class, in order to not type-erase the handler passed to async_connect (ensuring compatibility with coroutines). To allow unit tests that don't need a network, the Logic class is now templated on the Checker type. Currently the Manager provides its own io_service. However, this can easily be changed so that the io_service is provided upon construction.

Changes:

  • Remove unused SiteFiles dependency injection
  • Remove Callback and update signatures for public APIs
  • Remove obsolete functions
  • Move timer to overlay
  • Steps toward a shared io_service
  • Templated, simplified Checker

Reviewers: @ximinez @HowardHinnant

Note: The two oldest commits are from #614

The remoteAddress is the address as seen on the socket, which for
incoming connections has a random port chosen by the remote implementation
that is different from the port number used to accept connections by the
remote listening socket. The checkedAddress is the remote address as seen
on the socket, combined with the port advertised in the TMEndpoints message.
This fixes the reporting and metadata associated with addresses tested
for connectivity.
Conflicts:
	src/ripple/overlay/impl/PeerImp.h
@HowardHinnant
Copy link
Contributor

The travis failure looks spurious. This passes unittest and npm test for me on clang OS X.

@HowardHinnant
Copy link
Contributor

I'm very much appreciating the small commits. They are so much easier to review than a large monolithic commit.

@HowardHinnant
Copy link
Contributor

<phew> done!

@vinniefalco
Copy link
Contributor Author

@nbougalis
Copy link
Contributor

👍 but going through this really wiped me out.

@ximinez
Copy link
Collaborator

ximinez commented Oct 10, 2014

This review ate my brain. The changes are fantastic, but I suspect I never would have wrapped my head around it if it was one squashed commit.

@vinniefalco vinniefalco deleted the peerfinder branch October 10, 2014 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants