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

Initial tower-based peer implementation. #17

Merged
merged 32 commits into from
Oct 7, 2019
Merged

Initial tower-based peer implementation. #17

merged 32 commits into from
Oct 7, 2019

Conversation

hdevalence
Copy link
Contributor

Scratch work towards having a request/response-oriented Peer service. Branch is on top of #16.

@hdevalence
Copy link
Contributor Author

Note: I threw away the old branch and force-pushed a new one on top of it.

Unfortunately the generic `failure::Error` type is not `Clone` because
of its internals: rust-lang-deprecated/failure#148

The fix is to either switch to `Rc<Error>` or `Arc<Error>`, or to use a
custom `Fail` type.  In this case using a custom `Fail` might be best
but this commit just stubs out references to e.clone() until then.
failure::Error isn't Clone, so we wrap it in a cloneable handle and use
that everywhere.  Also, remove the error from ServerState::Failed,
because it's already held in the error_slot.
This required rearranging the PeerServer internals so that instead of
sending a response along a channel to the PeerClient, the PeerClient
creates a oneshot channel whose tx end is sent to the PeerServer and
whose rx end is owned by the <PeerClient as Service>::Future.
We need to be able to convert the errors returned by the
tower_buffer::Buffer service handle into failure::Errors, but in order
to test that any of this works we can ignore that for now.
We want the PeerServer to be generic over the kind of stream that it
has, so that the PeerConnector can use stream combinators to add hooks
into the streams that it constructs (e.g., to fire last-seen
timestamps).

A more natural design would be for the PeerServer struct to own both tx
and rx halves of the message stream, but this complicates the borrow
checker (since the main event loop needs to hold a future that controls
rx, it cannot allow something else to have mutable access to rx, so if
the rx end is part of self, it cannot make &mut self calls).
@hdevalence hdevalence marked this pull request as ready for review October 4, 2019 17:57
@hdevalence
Copy link
Contributor Author

Marking this as "ready for review" even though there's still a lot of cleanup to be done, but it does actually "technically work" now.

Copy link
Contributor

@dconnolly dconnolly left a comment

Choose a reason for hiding this comment

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

Reviewed via videochat. LGTM pending green build 🚀

@hdevalence hdevalence changed the title WIP Peer service Initial tower-based peer implementation. Oct 7, 2019
@hdevalence hdevalence merged commit ed608f7 into main Oct 7, 2019
@hdevalence hdevalence deleted the peer-service branch October 7, 2019 22:36
skyl added a commit to skyl/zebra that referenced this pull request Sep 25, 2024
)

## What

Restore funded/unfunded

## Why

Fix regression in prior simplification. Now we let anyone see unfunded
pages ...
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.

3 participants