Skip to content

Commit 28e02cc

Browse files
committed
f simplify ser
1 parent 73763ed commit 28e02cc

File tree

1 file changed

+4
-45
lines changed

1 file changed

+4
-45
lines changed

lightning/src/ln/channelmanager.rs

+4-45
Original file line numberDiff line numberDiff line change
@@ -927,58 +927,17 @@ impl RAAMonitorUpdateBlockingAction {
927927
}
928928
}
929929

930-
impl Writeable for RAAMonitorUpdateBlockingAction {
931-
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
932-
match self {
933-
RAAMonitorUpdateBlockingAction::ForwardedPaymentInboundClaim { channel_id, htlc_id } => {
934-
0u8.write(writer)?;
935-
write_tlv_fields!(writer, {
936-
(0, channel_id, required),
937-
(2, htlc_id, required),
938-
});
939-
},
940-
RAAMonitorUpdateBlockingAction::ClaimedMPPPayment { .. } => {
941-
1u8.write(writer)?;
942-
write_tlv_fields!(writer, {});
943-
// This is rebuilt on restart, so we don't bother writing it.
944-
},
945-
}
946-
Ok(())
947-
}
948-
}
930+
impl_writeable_tlv_based_enum_upgradable!(RAAMonitorUpdateBlockingAction,
931+
(0, ForwardedPaymentInboundClaim) => { (0, channel_id, required), (2, htlc_id, required) },
932+
unread_variants: ClaimedMPPPayment
933+
);
949934

950935
impl Readable for Option<RAAMonitorUpdateBlockingAction> {
951936
fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
952937
Ok(RAAMonitorUpdateBlockingAction::read(reader)?)
953938
}
954939
}
955940

956-
impl MaybeReadable for RAAMonitorUpdateBlockingAction {
957-
fn read<R: Read>(reader: &mut R) -> Result<Option<Self>, DecodeError> {
958-
match <u8 as Readable>::read(reader)? {
959-
0 => {
960-
_init_and_read_len_prefixed_tlv_fields!(reader, {
961-
(0, channel_id, required),
962-
(2, htlc_id, required),
963-
});
964-
Ok(Some(RAAMonitorUpdateBlockingAction::ForwardedPaymentInboundClaim {
965-
channel_id: channel_id.0.unwrap(),
966-
htlc_id: htlc_id.0.unwrap(),
967-
}))
968-
},
969-
// 1 is ClaimedMPPPayment and is handled in the general odd handling below
970-
x if x % 2 == 1 => {
971-
// Discard the contents
972-
let tlv_len: BigSize = Readable::read(reader)?;
973-
FixedLengthReader::new(reader, tlv_len.0)
974-
.eat_remaining().map_err(|_| DecodeError::ShortRead)?;
975-
Ok(None)
976-
},
977-
_ => Err(DecodeError::InvalidValue),
978-
}
979-
}
980-
}
981-
982941
/// State we hold per-peer.
983942
pub(super) struct PeerState<SP: Deref> where SP::Target: SignerProvider {
984943
/// `channel_id` -> `ChannelPhase`

0 commit comments

Comments
 (0)