projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
-f add ClosureReason tests
[rust-lightning]
/
lightning
/
src
/
ln
/
features.rs
diff --git
a/lightning/src/ln/features.rs
b/lightning/src/ln/features.rs
index b90748aa87b7e5cd55bf0461244fd2c654feb7eb..d1f6b89db4f87e968e3624289331c00c476875fe 100644
(file)
--- a/
lightning/src/ln/features.rs
+++ b/
lightning/src/ln/features.rs
@@
-22,8
+22,10
@@
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
//! [messages]: crate::ln::msgs
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
//! [messages]: crate::ln::msgs
+use io;
use prelude::*;
use core::{cmp, fmt};
use prelude::*;
use core::{cmp, fmt};
+use core::hash::{Hash, Hasher};
use core::marker::PhantomData;
use bitcoin::bech32;
use core::marker::PhantomData;
use bitcoin::bech32;
@@
-361,6
+363,11
@@
impl<T: sealed::Context> Clone for Features<T> {
}
}
}
}
}
}
+impl<T: sealed::Context> Hash for Features<T> {
+ fn hash<H: Hasher>(&self, hasher: &mut H) {
+ self.flags.hash(hasher);
+ }
+}
impl<T: sealed::Context> PartialEq for Features<T> {
fn eq(&self, o: &Self) -> bool {
self.flags.eq(&o.flags)
impl<T: sealed::Context> PartialEq for Features<T> {
fn eq(&self, o: &Self) -> bool {
self.flags.eq(&o.flags)
@@
-383,7
+390,7
@@
pub type InvoiceFeatures = Features<sealed::InvoiceContext>;
impl InitFeatures {
/// Writes all features present up to, and including, 13.
impl InitFeatures {
/// Writes all features present up to, and including, 13.
- pub(crate) fn write_up_to_13<W: Writer>(&self, w: &mut W) -> Result<(),
::std::
io::Error> {
+ pub(crate) fn write_up_to_13<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
let len = cmp::min(2, self.flags.len());
w.size_hint(len + 2);
(len as u16).write(w)?;
let len = cmp::min(2, self.flags.len());
w.size_hint(len + 2);
(len as u16).write(w)?;
@@
-547,7
+554,9
@@
impl<T: sealed::Context> Features<T> {
&self.flags
}
&self.flags
}
- pub(crate) fn requires_unknown_bits(&self) -> bool {
+ /// Returns true if this `Features` object contains unknown feature flags which are set as
+ /// "required".
+ pub fn requires_unknown_bits(&self) -> bool {
// Bitwise AND-ing with all even bits set except for known features will select required
// unknown features.
let byte_count = T::KNOWN_FEATURE_MASK.len();
// Bitwise AND-ing with all even bits set except for known features will select required
// unknown features.
let byte_count = T::KNOWN_FEATURE_MASK.len();
@@
-692,7
+701,7
@@
impl<T: sealed::ShutdownAnySegwit> Features<T> {
}
impl<T: sealed::Context> Writeable for Features<T> {
}
impl<T: sealed::Context> Writeable for Features<T> {
- fn write<W: Writer>(&self, w: &mut W) -> Result<(),
::std::
io::Error> {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
w.size_hint(self.flags.len() + 2);
(self.flags.len() as u16).write(w)?;
for f in self.flags.iter().rev() { // Swap back to big-endian
w.size_hint(self.flags.len() + 2);
(self.flags.len() as u16).write(w)?;
for f in self.flags.iter().rev() { // Swap back to big-endian
@@
-703,7
+712,7
@@
impl<T: sealed::Context> Writeable for Features<T> {
}
impl<T: sealed::Context> Readable for Features<T> {
}
impl<T: sealed::Context> Readable for Features<T> {
- fn read<R:
::std::
io::Read>(r: &mut R) -> Result<Self, DecodeError> {
+ fn read<R: io::Read>(r: &mut R) -> Result<Self, DecodeError> {
let mut flags: Vec<u8> = Readable::read(r)?;
flags.reverse(); // Swap to little-endian
Ok(Self {
let mut flags: Vec<u8> = Readable::read(r)?;
flags.reverse(); // Swap to little-endian
Ok(Self {