From d5cfd5ad5fd624e50be66288bef73b2401d5c9db Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 5 Jan 2021 11:15:32 +1000 Subject: [PATCH] Clarify the ClientRequest invariant Co-authored-by: Jane Lusby --- zebra-network/src/peer/client.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zebra-network/src/peer/client.rs b/zebra-network/src/peer/client.rs index f5e4e2ea2..5792f6558 100644 --- a/zebra-network/src/peer/client.rs +++ b/zebra-network/src/peer/client.rs @@ -33,6 +33,8 @@ pub(super) struct ClientRequest { /// future that may be moved around before it resolves. /// /// INVARIANT: `tx.send()` must be called before dropping `tx`. + /// + /// JUSTIFICATION: the `peer::Client` will translate all `Request`s into a `ClientRequest` which it sends to a background task, and if the send replies with `Ok(())` it will assume that it is safe to unconditionally poll the `Receiver` tied to the `Sender` used to create the `ClientRequest`. pub tx: MustUseOneshotSender>, /// The tracing context for the request, so that work the connection task does /// processing messages in the context of this request will have correct context.