projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Swap order of checks in `get_htlc_balance`
[rust-lightning]
/
lightning
/
src
/
onion_message
/
packet.rs
diff --git
a/lightning/src/onion_message/packet.rs
b/lightning/src/onion_message/packet.rs
index 8896941c8753789518944a260e15d3fa3112e6cd..a76371b39eb9fa12769e2144fb6cdd02067b70f7 100644
(file)
--- a/
lightning/src/onion_message/packet.rs
+++ b/
lightning/src/onion_message/packet.rs
@@
-264,8
+264,9
@@
ReadableArgs<(SharedSecret, &H, &L)> for Payload<<H as CustomOnionMessageHandler
}
/// When reading a packet off the wire, we don't know a priori whether the packet is to be forwarded
}
/// When reading a packet off the wire, we don't know a priori whether the packet is to be forwarded
-/// or received. Thus we read a ControlTlvs rather than reading a ForwardControlTlvs or
-/// ReceiveControlTlvs directly.
+/// or received. Thus we read a `ControlTlvs` rather than reading a [`ForwardTlvs`] or
+/// [`ReceiveTlvs`] directly. Also useful on the encoding side to keep forward and receive TLVs in
+/// the same iterator.
pub(crate) enum ControlTlvs {
/// This onion message is intended to be forwarded.
Forward(ForwardTlvs),
pub(crate) enum ControlTlvs {
/// This onion message is intended to be forwarded.
Forward(ForwardTlvs),
@@
-304,3
+305,12
@@
impl Readable for ControlTlvs {
Ok(payload_fmt)
}
}
Ok(payload_fmt)
}
}
+
+impl Writeable for ControlTlvs {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ match self {
+ Self::Forward(tlvs) => tlvs.write(w),
+ Self::Receive(tlvs) => tlvs.write(w),
+ }
+ }
+}