Repository navigation
Conversation
040bc40 to
8edde8a
Compare
Coverage Report for CI Build 47439821406Coverage decreased (-0.06%) to 88.758%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
8edde8a to
bdf1a94
Compare
|
The |
I think this const is simply a guard to not retry too quickly and not related to the discussion in #440 . I think this should be left in the cli. Also, not sure how I feel about naming this |
Oh yeah I got it tied up with what that was all about. we can leave it alone. I was thinking about this old comment #1658 (comment) and just got all the timing stuff mixed up. Noted about the naming |
787ae41 to
93e9ddf
Compare
05c0871 to
f712126
Compare
RequestHandler
80a1ba4 to
f0528e6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bbde7cf to
efd47fb
Compare
efd47fb to
44430a1
Compare
xstoicunicornx
left a comment
There was a problem hiding this comment.
Another API thing other than the comment below is that shouldn't ohttp keys be stored per directory?
Only really reviewed the shape of the request handler so far but I think these are design questions we want to think through first.
| /// Pass the session directory so a directory is never reached through | ||
| /// itself: a server serving as both relay and directory rejects the | ||
| /// self-loop request. | ||
| pub(crate) fn select_relay_excluding<R: Rng>( |
There was a problem hiding this comment.
I'm not sure about this API, its not quite intuitive what the exclusion is for and expecting implementers to appropriate add the right directory here feels open to misuse.
I kinda feel like if we are creating a request handler the directory should be set from the start rather than having the request handler also have to manage directories. But I also understand that a single request handler might want to handle multiple sessions that all have different directories.
Another issue that just occurred to me for this API is that for send sessions the payjoin directory might be one which doesn't exist in our directory list, and that is a case which we should still handle.
Maybe we can have a sub struct to allow requests specific to a directory? So you can have an API like RequestHandler::for_directory(directory_url).select_relay(rng)?
There was a problem hiding this comment.
Once a directory is selected for a session by the receiver it is exclusive as that is where the original POST lives. I am a little confused about the purpose of this for the sender.
44430a1 to
7c681c5
Compare
eabe5c4 to
4b4f43d
Compare
1d68b41 to
267e89a
Compare
Every v2 implementation had to copy payjoin-cli's relay selection and failover logic to talk to a directory safely. Move that logic into the library as `payjoin::request_handler` so implementations use the same logic instead of copying the reference code. `RequestHandler` holds the configured relays and an optional `RelayObserver`. It keeps no failure state, so one handler can be shared across sessions. Each request tries relays in a fresh random order and fails over on any error. A relay counts as successful only once the session accepts its response, and a relay equal to the session directory is skipped. The module is available with `v2`. The sealed `RelayExchange` trait is implemented for every session typestate that talks to the directory, so applications with their own HTTP client can drive the failover loop themselves. With `io`, `RequestHandler::post` runs that loop with reqwest, enforcing a 60s timeout and the OHTTP response size cap, and `fetch_ohttp_keys_from` falls back across candidate directories. `io` gates this because it pulls in reqwest. Add `directory()` accessors on `PjParam`, `Sender` and `Receiver` so requests are always routed via the session's own directory.
`relay_succeeded` and `relay_failed` mark the relay and don't carry logic so no mutation brings value.
payjoin-cli carried its own relay selection, failover and `RelayExchange` implementation. Replace them with the library's `RequestHandler` and drop the CLI copy. `MailroomManager` now builds a `RequestHandler` from the config and records relay outcomes for `relay-stats` through a `RelayObserver`. Pinned OHTTP keys are set on the chosen directory with `DirectoryHandle::with_ohttp_keys`, so no key fetch goes through a relay. With `_manual-tls` the root certificate is read once at startup and a bad path fails immediately. `http_agent` is now only needed by v1, so gate it on that feature.
267e89a to
c722b7e
Compare
This pulls the mailroom management logic into the core payjoin library to prevent footguns for implementers where possible.
To note this is a pretty big change in the sense that it adds quite a bit of
iogated logic.Coded and reviewed with help from GLM-5.3 the initial 2 commits are a direct grab from #1696, thanks for your contribution @bc1cindy!
Pull Request Checklist
Please confirm the following before requesting review: