@@ -59,9 +59,6 @@ pub enum DecodeError {
5959 /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
6060 /// syntactically incorrect, etc
6161 InvalidValue ,
62- /// Same as [`InvalidValue`], however this is set for gossip messages where we may not want to
63- /// force-close our channels with a counterparty and can instead send a [`Warning`] message.
64- InvalidGossipValue ,
6562 /// Buffer too short
6663 ShortRead ,
6764 /// A length descriptor in the packet didn't describe the later data correctly
@@ -72,17 +69,6 @@ pub enum DecodeError {
7269 /// The message included zlib-compressed values, which we don't support.
7370 UnsupportedCompression ,
7471}
75- impl DecodeError {
76- /// Map errors which may indicate a malformed message to `InvalidGossipValue` for use when
77- /// decoding gossip messages.
78- fn to_err_gossip_msg ( self ) -> Self {
79- match self {
80- DecodeError :: Io ( ioe) => DecodeError :: Io ( ioe) ,
81- DecodeError :: UnsupportedCompression => self ,
82- _ => DecodeError :: InvalidGossipValue ,
83- }
84- }
85- }
8672
8773/// An init message to be sent or received from a peer
8874#[ derive( Clone , Debug , PartialEq ) ]
@@ -992,7 +978,6 @@ impl fmt::Display for DecodeError {
992978 DecodeError :: UnknownVersion => f. write_str ( "Unknown realm byte in Onion packet" ) ,
993979 DecodeError :: UnknownRequiredFeature => f. write_str ( "Unknown required feature preventing decode" ) ,
994980 DecodeError :: InvalidValue => f. write_str ( "Nonsense bytes didn't map to the type they were interpreted as" ) ,
995- DecodeError :: InvalidGossipValue => f. write_str ( "Nonsense bytes didn't map to the type they were interpreted as in a gossip message" ) ,
996981 DecodeError :: ShortRead => f. write_str ( "Packet extended beyond the provided bytes" ) ,
997982 DecodeError :: BadLengthDescriptor => f. write_str ( "A length descriptor in the packet didn't describe the later data correctly" ) ,
998983 DecodeError :: Io ( ref e) => e. fmt ( f) ,
@@ -1453,8 +1438,8 @@ impl Writeable for UnsignedChannelAnnouncement {
14531438 }
14541439}
14551440
1456- impl UnsignedChannelAnnouncement {
1457- fn do_read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1441+ impl Readable for UnsignedChannelAnnouncement {
1442+ fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
14581443 Ok ( Self {
14591444 features : Readable :: read ( r) ?,
14601445 chain_hash : Readable :: read ( r) ?,
@@ -1467,11 +1452,6 @@ impl UnsignedChannelAnnouncement {
14671452 } )
14681453 }
14691454}
1470- impl Readable for UnsignedChannelAnnouncement {
1471- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1472- Self :: do_read ( r) . map_err ( |e| e. to_err_gossip_msg ( ) )
1473- }
1474- }
14751455
14761456impl_writeable ! ( ChannelAnnouncement , {
14771457 node_signature_1,
@@ -1502,8 +1482,8 @@ impl Writeable for UnsignedChannelUpdate {
15021482 }
15031483}
15041484
1505- impl UnsignedChannelUpdate {
1506- fn do_read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1485+ impl Readable for UnsignedChannelUpdate {
1486+ fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
15071487 let has_htlc_maximum_msat;
15081488 Ok ( Self {
15091489 chain_hash : Readable :: read ( r) ?,
@@ -1524,11 +1504,6 @@ impl UnsignedChannelUpdate {
15241504 } )
15251505 }
15261506}
1527- impl Readable for UnsignedChannelUpdate {
1528- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1529- Self :: do_read ( r) . map_err ( |e| e. to_err_gossip_msg ( ) )
1530- }
1531- }
15321507
15331508impl_writeable ! ( ChannelUpdate , {
15341509 signature,
@@ -1609,8 +1584,8 @@ impl Writeable for UnsignedNodeAnnouncement {
16091584 }
16101585}
16111586
1612- impl UnsignedNodeAnnouncement {
1613- fn do_read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1587+ impl Readable for UnsignedNodeAnnouncement {
1588+ fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
16141589 let features: NodeFeatures = Readable :: read ( r) ?;
16151590 let timestamp: u32 = Readable :: read ( r) ?;
16161591 let node_id: PublicKey = Readable :: read ( r) ?;
@@ -1670,11 +1645,6 @@ impl UnsignedNodeAnnouncement {
16701645 } )
16711646 }
16721647}
1673- impl Readable for UnsignedNodeAnnouncement {
1674- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1675- Self :: do_read ( r) . map_err ( |e| e. to_err_gossip_msg ( ) )
1676- }
1677- }
16781648
16791649impl_writeable ! ( NodeAnnouncement , {
16801650 signature,
0 commit comments