Skip to content

Commit acc293d

Browse files
committed
f remove unnecessary pub
1 parent 9362766 commit acc293d

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

lightning-types/src/features.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ use core::{cmp, fmt};
9696
use alloc::vec::Vec;
9797

9898
mod sealed {
99-
use super::{FeatureFlags, Features};
99+
use super::Features;
100100

101101
/// The context in which [`Features`] are applicable. Defines which features are known to the
102102
/// implementation, though specification of them as required or optional is up to the code
@@ -310,54 +310,54 @@ mod sealed {
310310

311311
/// Sets the feature's required (even) bit in the given flags.
312312
#[inline]
313-
fn set_required_bit(flags: &mut FeatureFlags) {
314-
if flags.len() <= Self::BYTE_OFFSET {
315-
flags.resize(Self::BYTE_OFFSET + 1, 0u8);
313+
fn set_required_bit(obj: &mut Features<Self>) {
314+
if obj.flags.len() <= Self::BYTE_OFFSET {
315+
obj.flags.resize(Self::BYTE_OFFSET + 1, 0u8);
316316
}
317317

318-
flags[Self::BYTE_OFFSET] |= Self::REQUIRED_MASK;
319-
flags[Self::BYTE_OFFSET] &= !Self::OPTIONAL_MASK;
318+
obj.flags[Self::BYTE_OFFSET] |= Self::REQUIRED_MASK;
319+
obj.flags[Self::BYTE_OFFSET] &= !Self::OPTIONAL_MASK;
320320
}
321321

322322
/// Sets the feature's optional (odd) bit in the given flags.
323323
#[inline]
324-
fn set_optional_bit(flags: &mut FeatureFlags) {
325-
if flags.len() <= Self::BYTE_OFFSET {
326-
flags.resize(Self::BYTE_OFFSET + 1, 0u8);
324+
fn set_optional_bit(obj: &mut Features<Self>) {
325+
if obj.flags.len() <= Self::BYTE_OFFSET {
326+
obj.flags.resize(Self::BYTE_OFFSET + 1, 0u8);
327327
}
328328

329-
flags[Self::BYTE_OFFSET] |= Self::OPTIONAL_MASK;
329+
obj.flags[Self::BYTE_OFFSET] |= Self::OPTIONAL_MASK;
330330
}
331331

332332
/// Clears the feature's required (even) and optional (odd) bits from the given
333333
/// flags.
334334
#[inline]
335-
fn clear_bits(flags: &mut FeatureFlags) {
336-
if flags.len() > Self::BYTE_OFFSET {
337-
flags[Self::BYTE_OFFSET] &= !Self::REQUIRED_MASK;
338-
flags[Self::BYTE_OFFSET] &= !Self::OPTIONAL_MASK;
335+
fn clear_bits(obj: &mut Features<Self>) {
336+
if obj.flags.len() > Self::BYTE_OFFSET {
337+
obj.flags[Self::BYTE_OFFSET] &= !Self::REQUIRED_MASK;
338+
obj.flags[Self::BYTE_OFFSET] &= !Self::OPTIONAL_MASK;
339339
}
340340

341-
let last_non_zero_byte = flags.iter().rposition(|&byte| byte != 0);
341+
let last_non_zero_byte = obj.flags.iter().rposition(|&byte| byte != 0);
342342
let size = if let Some(offset) = last_non_zero_byte { offset + 1 } else { 0 };
343-
flags.resize(size, 0u8);
343+
obj.flags.resize(size, 0u8);
344344
}
345345
}
346346

347347
impl <T: $feature> Features<T> {
348348
/// Set this feature as optional.
349349
pub fn $optional_setter(&mut self) {
350-
<T as $feature>::set_optional_bit(&mut self.flags);
350+
<T as $feature>::set_optional_bit(self);
351351
}
352352

353353
/// Set this feature as required.
354354
pub fn $required_setter(&mut self) {
355-
<T as $feature>::set_required_bit(&mut self.flags);
355+
<T as $feature>::set_required_bit(self);
356356
}
357357

358358
/// Unsets this feature.
359359
pub fn $clear(&mut self) {
360-
<T as $feature>::clear_bits(&mut self.flags);
360+
<T as $feature>::clear_bits(self);
361361
}
362362

363363
/// Checks if this feature is supported.
@@ -718,15 +718,17 @@ const DIRECT_ALLOC_BYTES: usize = if sealed::MIN_FEATURES_ALLOCATION_BYTES > 8 *
718718
};
719719
const _ASSERT: () = assert!(DIRECT_ALLOC_BYTES <= u8::MAX as usize);
720720

721-
/// The internal storage for feature flags. Public only for the [`sealed`] feature flag traits but
722-
/// generally should never be used directly.
723721
#[derive(Clone, PartialEq, Eq)]
724-
#[doc(hidden)]
725-
pub enum FeatureFlags {
722+
enum FeatureFlagsType {
726723
Held { bytes: [u8; DIRECT_ALLOC_BYTES], len: u8 },
727724
Heap(Vec<u8>),
728725
}
729726

727+
#[cfg(fuzzing)]
728+
pub use FeatureFlagsType as FeatureFlags;
729+
#[cfg(not(fuzzing))]
730+
use FeatureFlagsType as FeatureFlags;
731+
730732
impl FeatureFlags {
731733
fn empty() -> Self {
732734
Self::Held { bytes: [0; DIRECT_ALLOC_BYTES], len: 0 }
@@ -826,7 +828,7 @@ impl fmt::Debug for FeatureFlags {
826828
///
827829
/// This is not exported to bindings users as we map the concrete feature types below directly instead
828830
#[derive(Eq)]
829-
pub struct Features<T: sealed::Context> {
831+
pub struct Features<T: sealed::Context + ?Sized> {
830832
/// Note that, for convenience, flags is LITTLE endian (despite being big-endian on the wire)
831833
flags: FeatureFlags,
832834
mark: PhantomData<T>,
@@ -865,7 +867,7 @@ impl<T: sealed::Context> Hash for Features<T> {
865867
nonzero_flags.hash(hasher);
866868
}
867869
}
868-
impl<T: sealed::Context> PartialEq for Features<T> {
870+
impl<T: sealed::Context + ?Sized> PartialEq for Features<T> {
869871
fn eq(&self, o: &Self) -> bool {
870872
let mut o_iter = o.flags.iter();
871873
let mut self_iter = self.flags.iter();
@@ -1000,17 +1002,15 @@ impl ChannelTypeFeatures {
10001002
/// Constructs a ChannelTypeFeatures with only static_remotekey set
10011003
pub fn only_static_remote_key() -> Self {
10021004
let mut ret = Self::empty();
1003-
<sealed::ChannelTypeContext as sealed::StaticRemoteKey>::set_required_bit(&mut ret.flags);
1005+
<sealed::ChannelTypeContext as sealed::StaticRemoteKey>::set_required_bit(&mut ret);
10041006
ret
10051007
}
10061008

10071009
/// Constructs a ChannelTypeFeatures with anchors support
10081010
pub fn anchors_zero_htlc_fee_and_dependencies() -> Self {
10091011
let mut ret = Self::empty();
1010-
<sealed::ChannelTypeContext as sealed::StaticRemoteKey>::set_required_bit(&mut ret.flags);
1011-
<sealed::ChannelTypeContext as sealed::AnchorsZeroFeeHtlcTx>::set_required_bit(
1012-
&mut ret.flags,
1013-
);
1012+
<sealed::ChannelTypeContext as sealed::StaticRemoteKey>::set_required_bit(&mut ret);
1013+
<sealed::ChannelTypeContext as sealed::AnchorsZeroFeeHtlcTx>::set_required_bit(&mut ret);
10141014
ret
10151015
}
10161016
}

0 commit comments

Comments
 (0)