From: Matt Corallo Date: Wed, 19 Sep 2018 21:37:51 +0000 (-0400) Subject: Make message fields pub(crate) and hide a few internal fns X-Git-Tag: v0.0.12~304^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=9373c5993fcc4943f31e20fb0e0367d2bddec596;p=rust-lightning Make message fields pub(crate) and hide a few internal fns --- diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index ded2a99dc..cd38c9c1a 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -269,7 +269,7 @@ impl PartialEq for ChannelMonitor { } impl ChannelMonitor { - pub fn new(revocation_base_key: &SecretKey, delayed_payment_base_key: &PublicKey, htlc_base_key: &SecretKey, our_to_self_delay: u16, destination_script: Script) -> ChannelMonitor { + pub(super) fn new(revocation_base_key: &SecretKey, delayed_payment_base_key: &PublicKey, htlc_base_key: &SecretKey, our_to_self_delay: u16, destination_script: Script) -> ChannelMonitor { ChannelMonitor { funding_txo: None, commitment_transaction_number_obscure_factor: 0, @@ -903,7 +903,7 @@ impl ChannelMonitor { //we want to leave out (eg funding_txo, etc). /// Can only fail if idx is < get_min_seen_secret - pub fn get_secret(&self, idx: u64) -> Result<[u8; 32], HandleError> { + pub(super) fn get_secret(&self, idx: u64) -> Result<[u8; 32], HandleError> { for i in 0..self.old_secrets.len() { if (idx & (!((1 << i) - 1))) == self.old_secrets[i].1 { return Ok(ChannelMonitor::derive_secret(self.old_secrets[i].0, i as u8, idx)) @@ -913,7 +913,7 @@ impl ChannelMonitor { Err(HandleError{err: "idx too low", action: None}) } - pub fn get_min_seen_secret(&self) -> u64 { + pub(super) fn get_min_seen_secret(&self) -> u64 { //TODO This can be optimized? let mut min = 1 << 48; for &(_, idx) in self.old_secrets.iter() { @@ -1403,7 +1403,7 @@ impl ChannelMonitor { watch_outputs } - pub fn would_broadcast_at_height(&self, height: u32) -> bool { + pub(super) fn would_broadcast_at_height(&self, height: u32) -> bool { if let Some(ref cur_local_tx) = self.current_local_signed_commitment_tx { for &(ref htlc, _, _) in cur_local_tx.htlc_outputs.iter() { if htlc.cltv_expiry <= height + CLTV_CLAIM_BUFFER { diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 92e900a21..c43a5dc9c 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -9,7 +9,7 @@ use std::{cmp, fmt}; use std::io::Read; use std::result::Result; -use util::{byte_utils, internal_traits, events}; +use util::{byte_utils, events}; use util::ser::{Readable, Writeable, Writer}; #[derive(Debug)] @@ -44,23 +44,23 @@ pub struct LocalFeatures { } impl LocalFeatures { - pub fn new() -> LocalFeatures { + pub(crate) fn new() -> LocalFeatures { LocalFeatures { flags: Vec::new(), } } - pub fn supports_data_loss_protect(&self) -> bool { + pub(crate) fn supports_data_loss_protect(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & 3) != 0 } - pub fn requires_data_loss_protect(&self) -> bool { + pub(crate) fn requires_data_loss_protect(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & 1) != 0 } - pub fn initial_routing_sync(&self) -> bool { + pub(crate) fn initial_routing_sync(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & (1 << 3)) != 0 } - pub fn set_initial_routing_sync(&mut self) { + pub(crate) fn set_initial_routing_sync(&mut self) { if self.flags.len() == 0 { self.flags.resize(1, 1 << 3); } else { @@ -68,14 +68,14 @@ impl LocalFeatures { } } - pub fn supports_upfront_shutdown_script(&self) -> bool { + pub(crate) fn supports_upfront_shutdown_script(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & (3 << 4)) != 0 } - pub fn requires_upfront_shutdown_script(&self) -> bool { + pub(crate) fn requires_upfront_shutdown_script(&self) -> bool { self.flags.len() > 0 && (self.flags[0] & (1 << 4)) != 0 } - pub fn requires_unknown_bits(&self) -> bool { + pub(crate) fn requires_unknown_bits(&self) -> bool { for (idx, &byte) in self.flags.iter().enumerate() { if idx != 0 && (byte & 0x55) != 0 { return true; @@ -86,7 +86,7 @@ impl LocalFeatures { return false; } - pub fn supports_unknown_bits(&self) -> bool { + pub(crate) fn supports_unknown_bits(&self) -> bool { for (idx, &byte) in self.flags.iter().enumerate() { if idx != 0 && byte != 0 { return true; @@ -105,13 +105,13 @@ pub struct GlobalFeatures { } impl GlobalFeatures { - pub fn new() -> GlobalFeatures { + pub(crate) fn new() -> GlobalFeatures { GlobalFeatures { flags: Vec::new(), } } - pub fn requires_unknown_bits(&self) -> bool { + pub(crate) fn requires_unknown_bits(&self) -> bool { for &byte in self.flags.iter() { if (byte & 0x55) != 0 { return true; @@ -120,7 +120,7 @@ impl GlobalFeatures { return false; } - pub fn supports_unknown_bits(&self) -> bool { + pub(crate) fn supports_unknown_bits(&self) -> bool { for &byte in self.flags.iter() { if byte != 0 { return true; @@ -131,160 +131,160 @@ impl GlobalFeatures { } pub struct Init { - pub global_features: GlobalFeatures, - pub local_features: LocalFeatures, + pub(crate) global_features: GlobalFeatures, + pub(crate) local_features: LocalFeatures, } pub struct ErrorMessage { - pub channel_id: [u8; 32], - pub data: String, + pub(crate) channel_id: [u8; 32], + pub(crate) data: String, } pub struct Ping { - pub ponglen: u16, - pub byteslen: u16, + pub(crate) ponglen: u16, + pub(crate) byteslen: u16, } pub struct Pong { - pub byteslen: u16, + pub(crate) byteslen: u16, } pub struct OpenChannel { - pub chain_hash: Sha256dHash, - pub temporary_channel_id: [u8; 32], - pub funding_satoshis: u64, - pub push_msat: u64, - pub dust_limit_satoshis: u64, - pub max_htlc_value_in_flight_msat: u64, - pub channel_reserve_satoshis: u64, - pub htlc_minimum_msat: u64, - pub feerate_per_kw: u32, - pub to_self_delay: u16, - pub max_accepted_htlcs: u16, - pub funding_pubkey: PublicKey, - pub revocation_basepoint: PublicKey, - pub payment_basepoint: PublicKey, - pub delayed_payment_basepoint: PublicKey, - pub htlc_basepoint: PublicKey, - pub first_per_commitment_point: PublicKey, - pub channel_flags: u8, - pub shutdown_scriptpubkey: Option