@@ -59,9 +59,6 @@ pub enum DecodeError {
59
59
/// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was
60
60
/// syntactically incorrect, etc
61
61
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 ,
65
62
/// Buffer too short
66
63
ShortRead ,
67
64
/// A length descriptor in the packet didn't describe the later data correctly
@@ -72,17 +69,6 @@ pub enum DecodeError {
72
69
/// The message included zlib-compressed values, which we don't support.
73
70
UnsupportedCompression ,
74
71
}
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
- }
86
72
87
73
/// An init message to be sent or received from a peer
88
74
#[ derive( Clone , Debug , PartialEq ) ]
@@ -992,7 +978,6 @@ impl fmt::Display for DecodeError {
992
978
DecodeError :: UnknownVersion => f. write_str ( "Unknown realm byte in Onion packet" ) ,
993
979
DecodeError :: UnknownRequiredFeature => f. write_str ( "Unknown required feature preventing decode" ) ,
994
980
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" ) ,
996
981
DecodeError :: ShortRead => f. write_str ( "Packet extended beyond the provided bytes" ) ,
997
982
DecodeError :: BadLengthDescriptor => f. write_str ( "A length descriptor in the packet didn't describe the later data correctly" ) ,
998
983
DecodeError :: Io ( ref e) => e. fmt ( f) ,
@@ -1453,8 +1438,8 @@ impl Writeable for UnsignedChannelAnnouncement {
1453
1438
}
1454
1439
}
1455
1440
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 > {
1458
1443
Ok ( Self {
1459
1444
features : Readable :: read ( r) ?,
1460
1445
chain_hash : Readable :: read ( r) ?,
@@ -1467,11 +1452,6 @@ impl UnsignedChannelAnnouncement {
1467
1452
} )
1468
1453
}
1469
1454
}
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
- }
1475
1455
1476
1456
impl_writeable ! ( ChannelAnnouncement , {
1477
1457
node_signature_1,
@@ -1502,8 +1482,8 @@ impl Writeable for UnsignedChannelUpdate {
1502
1482
}
1503
1483
}
1504
1484
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 > {
1507
1487
let has_htlc_maximum_msat;
1508
1488
Ok ( Self {
1509
1489
chain_hash : Readable :: read ( r) ?,
@@ -1524,11 +1504,6 @@ impl UnsignedChannelUpdate {
1524
1504
} )
1525
1505
}
1526
1506
}
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
- }
1532
1507
1533
1508
impl_writeable ! ( ChannelUpdate , {
1534
1509
signature,
@@ -1609,8 +1584,8 @@ impl Writeable for UnsignedNodeAnnouncement {
1609
1584
}
1610
1585
}
1611
1586
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 > {
1614
1589
let features: NodeFeatures = Readable :: read ( r) ?;
1615
1590
let timestamp: u32 = Readable :: read ( r) ?;
1616
1591
let node_id: PublicKey = Readable :: read ( r) ?;
@@ -1670,11 +1645,6 @@ impl UnsignedNodeAnnouncement {
1670
1645
} )
1671
1646
}
1672
1647
}
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
- }
1678
1648
1679
1649
impl_writeable ! ( NodeAnnouncement , {
1680
1650
signature,
0 commit comments