]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f - Put channel_liquidities into TLV
authorJeffrey Czyz <jkczyz@gmail.com>
Tue, 1 Feb 2022 23:35:47 +0000 (17:35 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 2 Feb 2022 16:51:47 +0000 (10:51 -0600)
lightning/src/routing/scoring.rs

index c7f36c895b52c439abf2151ea4b3036d0c6be535..4fef17f9b99b55ae156f8a69fea60dcafdf95ceb 100644 (file)
@@ -719,8 +719,9 @@ impl<G: Deref<Target = NetworkGraph>> Score for ProbabilisticScorer<G> {
 impl<G: Deref<Target = NetworkGraph>> Writeable for ProbabilisticScorer<G> {
        #[inline]
        fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
-               self.channel_liquidities.write(w)?;
-               write_tlv_fields!(w, {});
+               write_tlv_fields!(w, {
+                       (0, self.channel_liquidities, required)
+               });
                Ok(())
        }
 }
@@ -732,13 +733,15 @@ for ProbabilisticScorer<G> {
                r: &mut R, args: (ProbabilisticScoringParameters, G)
        ) -> Result<Self, DecodeError> {
                let (params, network_graph) = args;
-               let res = Ok(Self {
+               let mut channel_liquidities = HashMap::new();
+               read_tlv_fields!(r, {
+                       (0, channel_liquidities, required)
+               });
+               Ok(Self {
                        params,
                        network_graph,
-                       channel_liquidities: Readable::read(r)?,
-               });
-               read_tlv_fields!(r, {});
-               res
+                       channel_liquidities,
+               })
        }
 }