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 RPC and implement hello protocol #246

Merged
merged 4 commits into from
Mar 2, 2020
Merged

Conversation

austinabell
Copy link
Contributor

Summary of changes
Changes introduced in this pull request:

  • Refactors RPC to allow for more protocols
    • I started doing a bigger refactor, but it was very extensive and didn't think it was worth the time since it works like this. Can revisit though once we update libp2p dependency
  • Implements hello protocol
  • Updated RPC tests to more efficiently use futures and not waste CPU polling unnecessarily

The hello protocol matches the spec definition but does not match lotus, lotus has only one Hello message type and has optional map fields that they serialize for both the request and response. It was a huge pain to try to retrieve their exact format so I will leave this for now but will probably have to switch it to match lotus to test our syncing functionality.

Reference issue to close (if applicable)

Closes #194

Other information and links

@@ -51,3 +50,36 @@ impl std::fmt::Display for RPCEvent {
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency should this be its own file error.rs?

Blocksync(BlockSyncResponse),
Hello(HelloResponse),
}

/// Protocol upgrade for inbound RPC requests. Currently supports Blocksync.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment should be updated to include mention of hello protocol?

impl RPCRequest {
pub fn supported_protocols(&self) -> Vec<&'static [u8]> {
match self {
// add more protocols when versions/encodings are supported
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a TODO here

swarm_stream.get_mut().send_rpc(peer_id, RPCEvent::Response(1, RPCResponse::Blocksync(BlockSyncResponse {
chain: vec![],
status: 203,
message: "handling requests not implemented".to_owned(),
})));
}
RPCEvent::Request(req_id, RPCRequest::Hello(message)) => {

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove spacing

@dutterbutter
Copy link
Contributor

This should also close #194

@austinabell
Copy link
Contributor Author

This should also close #194

It has that in the PR description already :)

Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

Lvvvvvgtm

@austinabell austinabell merged commit 7b5d8db into master Mar 2, 2020
@austinabell austinabell deleted the austin/rpcrefactor branch March 2, 2020 16:20
@austinabell austinabell mentioned this pull request Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TASK]🗃️ Updates from Spec | Hello Protocol
3 participants