Repository navigation
handshake: an async handshake, and AsyncConnection::connect_with/accept_with - #65
Merged
Merged
Conversation
…pt_with A custom (namespaced) handshake could only run on a blocking connection: `Handshake` is over the blocking `Transport`, and `AsyncConnection` had only `comline@1` (`connect`/`accept`/`handshake`) and `new_unverified`. - `handshake::AsyncHandshake` (feature `async`): `name`, `initiate`, `respond`, the latter two returning `Send` futures over an `AsyncTransport`. No executor dependency; implementors write `async fn`s. - `ComlineHandshake` and `NoHandshake` implement it. `comline@1` builds and checks its frame with the same code as the blocking exchange, so the bytes are the same. - `AsyncConnection::connect_with` / `accept_with`, shaped like the blocking `Connection`'s: (transport, format, framing, &mut handshake, ir_hash). `connect`, `accept` and `handshake` now go through them with `ComlineHandshake`. Tests (tests/async_handshake.rs): a custom handshake runs on both ends and a call goes through after it; one that refuses refuses both ends; the official handshakes through the `_with` constructors; and `comline@1` over async sends exactly each conformance vector's bytes (initiate and respond, checked against the blocking exchange too) and refuses each reject vector.
Closed
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets a custom (namespaced) handshake run on an async connection. Until now
Handshakeworked only over the blockingTransport, andAsyncConnectioncould run onlycomline@1or skip the handshake (new_unverified).API
HandshakeandConnection::connect_with/accept_with. Nothing from an executor is needed (thefuturescrates only, as withAsyncDispatch), and implementors writeasync fns.ComlineHandshakeandNoHandshakeimplement it.comline@1builds and checks its frame with the same code the blocking exchange uses, so it sends the same bytes.AsyncConnection::connect,acceptandhandshakenow run throughconnect_with/accept_withwithComlineHandshake. Their behaviour is unchanged.handshakeandasync_connectionmodule docs.Tests
The new
tests/async_handshake.rscovers:com.acme.hello@1-style) runs on both ends of an async connection, and a call goes through after it. A mismatch refuses both ends.ComlineHandshakeandNoHandshakework through the_withconstructors.conformance/vectors/handshake.json,comline@1sends exactly that vector's bytes, both over async (initiate and respond) and blocking. The async exchange also refuses eachrejectvector. The vectors are unchanged.All of these pass locally:
cargo test,cargo test -p comline-runtime --features tokio, the--no-default-features --features allocandalloc,jsonrpctests, andcargo metadata --locked.Unblocks the async half of comline-rust#81's mapped handshakes.