Don't serialize FixedPenaltyScorer parameters
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 21 Mar 2022 20:29:21 +0000 (15:29 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 25 Mar 2022 13:53:19 +0000 (08:53 -0500)
Serializing scorer parameters makes it difficult to experiment with
different settings.

lightning/src/routing/scoring.rs

index d8b1740c19ec2f1ec6098fb5f941c5e387845865..2ccfba08d8d61b367bb8c04a8c5ee8aa4cbe2988 100644 (file)
@@ -197,10 +197,6 @@ pub struct FixedPenaltyScorer {
        penalty_msat: u64,
 }
 
-impl_writeable_tlv_based!(FixedPenaltyScorer, {
-       (0, penalty_msat, required),
-});
-
 impl FixedPenaltyScorer {
        /// Creates a new scorer using `penalty_msat`.
        pub fn with_penalty(penalty_msat: u64) -> Self {
@@ -218,6 +214,22 @@ impl Score for FixedPenaltyScorer {
        fn payment_path_successful(&mut self, _path: &[&RouteHop]) {}
 }
 
+impl Writeable for FixedPenaltyScorer {
+       #[inline]
+       fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+               write_tlv_fields!(w, {});
+               Ok(())
+       }
+}
+
+impl ReadableArgs<u64> for FixedPenaltyScorer {
+       #[inline]
+       fn read<R: Read>(r: &mut R, penalty_msat: u64) -> Result<Self, DecodeError> {
+               read_tlv_fields!(r, {});
+               Ok(Self { penalty_msat })
+       }
+}
+
 /// [`Score`] implementation that provides reasonable default behavior.
 ///
 /// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with