Skip to content

Commit

Permalink
Introduce Documentation and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaavan committed Mar 15, 2024
1 parent 63eaff3 commit 72fa9ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
9 changes: 4 additions & 5 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9416,15 +9416,15 @@ where
}
}

impl<M: Deref, BI: Deref, ES: Deref, NS: Deref, SP: Deref, FE: Deref, R: Deref, L: Deref>
OffersMessageHandler for ChannelManager<M, BI, ES, NS, SP, FE, R, L>
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
OffersMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, L>
where
M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
BI::Target: BroadcasterInterface,
T::Target: BroadcasterInterface,
ES::Target: EntropySource,
NS::Target: NodeSigner,
SP::Target: SignerProvider,
FE::Target: FeeEstimator,
F::Target: FeeEstimator,
R::Target: Router,
L::Target: Logger,
{
Expand Down Expand Up @@ -9546,7 +9546,6 @@ where
None
},
};

if let Some(response) = response_option {
responder.respond(response)
} else {
Expand Down
20 changes: 16 additions & 4 deletions lightning/src/onion_message/messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ impl OnionMessageRecipient {
}
}

/// A enum to handle received [`OnionMessage`]
/// The `ReceivedOnionMessage` enum represents messages received by the `OnionMessageHandler`.
///
/// This enum encompasses two variants:
/// - `WithReplyPath`: Represents a message that can be responded to, including the original message,
/// an optional path id, and a responder.
/// - `WithoutReplyPath`: Represents a message without the possibility of response because of absence of a reply_path.
/// It contains the original message and an optional path id.
///
pub enum ReceivedOnionMessage<T>
where
T: OnionMessageContents
Expand Down Expand Up @@ -284,15 +291,15 @@ where
}
}

/// A struct handling response to an [`OnionMessage`]
/// The `Responder` struct manages responses to [`ReceivedOnionMessage`]
pub struct Responder<T>
where
T: OnionMessageContents
{
reply_path: BlindedPath,

// This phantom Data is used to ensure that we use T in the struct definition
// This allow us to ensure at compile time that the received message type and response type will be same
/// A marker field, ensuring compile-time enforcement that the message
/// type used in the struct definition matches the response type.
_phantom: PhantomData<T>
}

Expand All @@ -308,6 +315,11 @@ where
}
}

/// The `ResponseInstruction` enum represents instructions for responding to [`ReceivedOnionMessage`].
///
/// It includes the following variants:
/// - `HaveResponse`: Indicates that a response is available, and can be sent using reply_path.
/// - `NoResponse`: Indicates that no response is available.
pub enum ResponseInstruction<T: OnionMessageContents> {
HaveResponse {
response: T,
Expand Down

0 comments on commit 72fa9ab

Please sign in to comment.