X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Fmsgs.rs;h=1ad798fd4bfaf2417d20fdeb4030dd876d7dd77c;hb=e5bedc43d27ad94ab2027be0ba7eb68398fc01c8;hp=b50e35b96dc14c62966aab1e8a3c85ca19097bd7;hpb=c94e53d9ddd65816b29af07ac075f542f0f5b37f;p=rust-lightning diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index b50e35b9..1ad798fd 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -47,8 +47,6 @@ pub enum DecodeError { InvalidValue, /// Buffer too short ShortRead, - /// node_announcement included more than one address of a given type! - ExtraAddressesPerType, /// A length descriptor in the packet didn't describe the later data correctly BadLengthDescriptor, /// Error from std::io @@ -304,6 +302,9 @@ impl NetAddress { &NetAddress::OnionV3 { .. } => { 37 }, } } + + /// The maximum length of any address descriptor, not including the 1-byte type + pub(crate) const MAX_LEN: u16 = 37; } impl Writeable for NetAddress { @@ -336,9 +337,9 @@ impl Writeable for NetAddress { } } -impl Readable for Result { - fn read(reader: &mut R) -> Result, DecodeError> { - let byte = >::read(reader)?; +impl Readable for Result { + fn read(reader: &mut R) -> Result, DecodeError> { + let byte = ::read(reader)?; match byte { 1 => { Ok(Ok(NetAddress::IPv4 { @@ -599,10 +600,11 @@ pub trait RoutingMessageHandler : Send + Sync { fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate); /// Gets a subset of the channel announcements and updates required to dump our routing table /// to a remote node, starting at the short_channel_id indicated by starting_point and - /// including batch_amount entries. + /// including the batch_amount entries immediately higher in numerical value than starting_point. fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(ChannelAnnouncement, ChannelUpdate, ChannelUpdate)>; /// Gets a subset of the node announcements required to dump our routing table to a remote node, - /// starting at the node *after* the provided publickey and including batch_amount entries. + /// starting at the node *after* the provided publickey and including batch_amount entries + /// immediately higher (as defined by ::cmp) than starting_point. /// If None is provided for starting_point, we start at the first node. fn get_next_node_announcements(&self, starting_point: Option<&PublicKey>, batch_amount: u8) -> Vec; /// Returns whether a full sync should be requested from a peer. @@ -677,7 +679,6 @@ impl Error for DecodeError { DecodeError::UnknownRequiredFeature => "Unknown required feature preventing decode", DecodeError::InvalidValue => "Nonsense bytes didn't map to the type they were interpreted as", DecodeError::ShortRead => "Packet extended beyond the provided bytes", - DecodeError::ExtraAddressesPerType => "More than one address of a single type", DecodeError::BadLengthDescriptor => "A length descriptor in the packet didn't describe the later data correctly", DecodeError::Io(ref e) => e.description(), } @@ -718,9 +719,9 @@ impl Writeable for OptionalField