Add annotations for things which we cannot (yet) expose
authorMatt Corallo <git@bluematt.me>
Tue, 12 May 2020 17:48:07 +0000 (13:48 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 11 Sep 2020 02:03:30 +0000 (22:03 -0400)
lightning/src/chain/chaininterface.rs
lightning/src/chain/transaction.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/channelmonitor.rs
lightning/src/ln/features.rs
lightning/src/ln/msgs.rs
lightning/src/routing/network_graph.rs
lightning/src/util/logger.rs
lightning/src/util/ser.rs

index 2da2ae8c7eb618a49308e664e4a8edd50266bd58..295c337e29d905ff8e6e5b28ffb4043b76429148 100644 (file)
@@ -226,6 +226,8 @@ impl ChainWatchedUtil {
 /// parameters with static lifetimes). Other times you can afford a reference, which is more
 /// efficient, in which case BlockNotifierRef is a more appropriate type. Defining these type
 /// aliases prevents issues such as overly long function definitions.
+///
+/// (C-not exported) as we let clients handle any reference counting they need to do
 pub type BlockNotifierArc<C> = Arc<BlockNotifier<'static, Arc<ChainListener>, C>>;
 
 /// BlockNotifierRef is useful when you want a BlockNotifier that points to ChainListeners
@@ -273,6 +275,8 @@ impl<'a, CL: Deref + 'a, C: Deref> BlockNotifier<'a, CL, C>
        /// If the same listener is registered multiple times, unregistering
        /// will remove ALL occurrences of that listener. Comparison is done using
        /// the pointer returned by the Deref trait implementation.
+       ///
+       /// (C-not exported) because the equality check would always fail
        pub fn unregister_listener(&self, listener: CL) {
                let mut vec = self.listeners.lock().unwrap();
                // item is a ref to an abstract thing that dereferences to a ChainListener,
index c4917313f2988045a79c656945f76ddaffb75398..946562bc1781f95f77f62ce4aa252509d77eec10 100644 (file)
@@ -35,6 +35,7 @@ impl OutPoint {
        }
 
        /// Converts this OutPoint into the OutPoint field as used by rust-bitcoin
+       /// (C-not exported) as the same type is used universally in the C bindings for all outpoints
        pub fn into_bitcoin_outpoint(self) -> BitcoinOutPoint {
                BitcoinOutPoint {
                        txid: self.txid,
index ee99012c5846922d7265f2d7336d9d7fec129ed3..148fdfa4854e0f906e6c45ad4299a15b26d2d36a 100644 (file)
@@ -180,12 +180,15 @@ pub(super) enum HTLCFailReason {
 }
 
 /// payment_hash type, use to cross-lock hop
+/// (C-not exported) as we just use [u8; 32] directly
 #[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
 pub struct PaymentHash(pub [u8;32]);
 /// payment_preimage type, use to route payment between hop
+/// (C-not exported) as we just use [u8; 32] directly
 #[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
 pub struct PaymentPreimage(pub [u8;32]);
 /// payment_secret type, use to authenticate sender to the receiver and tie MPP HTLCs together
+/// (C-not exported) as we just use [u8; 32] directly
 #[derive(Hash, Copy, Clone, PartialEq, Eq, Debug)]
 pub struct PaymentSecret(pub [u8;32]);
 
@@ -2919,6 +2922,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
        /// If successful, will generate a UpdateHTLCs event, so you should probably poll
        /// PeerManager::process_events afterwards.
        /// Note: This API is likely to change!
+       /// (C-not exported) Cause its doc(hidden) anyway
        #[doc(hidden)]
        pub fn update_fee(&self, channel_id: [u8;32], feerate_per_kw: u32) -> Result<(), APIError> {
                let _ = self.total_consistency_lock.read().unwrap();
@@ -3738,7 +3742,6 @@ pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T:
         F::Target: FeeEstimator,
         L::Target: Logger,
 {
-
        /// The keys provider which will give us relevant keys. Some keys will be loaded during
        /// deserialization.
        pub keys_manager: K,
@@ -3775,6 +3778,8 @@ pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T:
        ///
        /// In such cases the latest local transactions will be sent to the tx_broadcaster included in
        /// this struct.
+       ///
+       /// (C-not exported) because we have no HashMap bindings
        pub channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<ChanSigner>>,
 }
 
index 4ba7eb2d2d00e1f6b5ce3b0dad168d8de436c594..36369644344591a177ced3c1ca020479b9995f06 100644 (file)
@@ -180,6 +180,8 @@ impl_writeable!(HTLCUpdate, 0, { payment_hash, payment_preimage, source });
 ///
 /// If you're using this for local monitoring of your own channels, you probably want to use
 /// `OutPoint` as the key, which will give you a ManyChannelMonitor implementation.
+///
+/// (C-not exported) due to an unconstrained generic in `Key`
 pub struct SimpleManyChannelMonitor<Key, ChanSigner: ChannelKeys, T: Deref, F: Deref, L: Deref, C: Deref>
        where T::Target: BroadcasterInterface,
         F::Target: FeeEstimator,
@@ -1421,6 +1423,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
 
        /// Gets a list of txids, with their output scripts (in the order they appear in the
        /// transaction), which we must learn about spends of via block_connected().
+       ///
+       /// (C-not exported) because we have no HashMap bindings
        pub fn get_outputs_to_watch(&self) -> &HashMap<Txid, Vec<Script>> {
                &self.outputs_to_watch
        }
@@ -1429,6 +1433,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
        /// Generally useful when deserializing as during normal operation the return values of
        /// block_connected are sufficient to ensure all relevant outpoints are being monitored (note
        /// that the get_funding_txo outpoint and transaction must also be monitored for!).
+       ///
+       /// (C-not exported) as there is no practical way to track lifetimes of returned values.
        pub fn get_monitored_outpoints(&self) -> Vec<(Txid, u32, &Script)> {
                let mut res = Vec::with_capacity(self.remote_commitment_txn_on_chain.len() * 2);
                for (ref txid, &(_, ref outputs)) in self.remote_commitment_txn_on_chain.iter() {
index 8966d8d40b31476c8ffb67e1e794d907823dd6b1..f573ac4c43abd910c96764e123913901a3af1f2e 100644 (file)
@@ -279,6 +279,8 @@ mod sealed {
 
 /// Tracks the set of features which a node implements, templated by the context in which it
 /// appears.
+///
+/// (C-not exported) as we map the concrete feature types below directly instead
 pub struct Features<T: sealed::Context> {
        /// Note that, for convenience, flags is LITTLE endian (despite being big-endian on the wire)
        flags: Vec<u8>,
index 22bca6ee19c4e71624cbe20d33dec1d248945fde..22eefb226e71317f4d145d41c831949ceccece1e 100644 (file)
@@ -646,6 +646,7 @@ pub enum HTLCFailChannelUpdate {
 /// As we wish to serialize these differently from Option<T>s (Options get a tag byte, but
 /// OptionalFeild simply gets Present if there are enough bytes to read into it), we have a
 /// separate enum type for them.
+/// (C-not exported) due to a free generic in T
 #[derive(Clone, PartialEq, Debug)]
 pub enum OptionalField<T> {
        /// Optional field is included in message
index 0a779e1e06cabac5ff94a4c6e8c288abc47cb932..1a4a8c1a637e7a1e0c0df8a0294f0750265f40b8 100644 (file)
@@ -526,13 +526,19 @@ impl fmt::Display for NetworkGraph {
 
 impl NetworkGraph {
        /// Returns all known valid channels' short ids along with announced channel info.
+       ///
+       /// (C-not exported) because we have no mapping for `BTreeMap`s
        pub fn get_channels<'a>(&'a self) -> &'a BTreeMap<u64, ChannelInfo> { &self.channels }
        /// Returns all known nodes' public keys along with announced node info.
+       ///
+       /// (C-not exported) because we have no mapping for `BTreeMap`s
        pub fn get_nodes<'a>(&'a self) -> &'a BTreeMap<PublicKey, NodeInfo> { &self.nodes }
 
        /// Get network addresses by node id.
        /// Returns None if the requested node is completely unknown,
        /// or if node announcement for the node was never received.
+       ///
+       /// (C-not exported) as there is no practical way to track lifetimes of returned values.
        pub fn get_addresses<'a>(&'a self, pubkey: &PublicKey) -> Option<&'a Vec<NetAddress>> {
                if let Some(node) = self.nodes.get(pubkey) {
                        if let Some(node_info) = node.announcement_info.as_ref() {
index 6d42fbf01c64c45a8259ce59d3308f0ab5ec2f6d..acd6d323e8f319e9b3c84550ab099d2258f486cb 100644 (file)
@@ -86,6 +86,7 @@ impl Level {
 
 /// A Record, unit of logging output with Metadata to enable filtering
 /// Module_path, file, line to inform on log's source
+/// (C-not exported) - we convert to a const char* instead
 #[derive(Clone,Debug)]
 pub struct Record<'a> {
        /// The verbosity level of the message.
@@ -102,6 +103,7 @@ pub struct Record<'a> {
 
 impl<'a> Record<'a> {
        /// Returns a new Record.
+       /// (C-not exported) as fmt can't be used in C
        #[inline]
        pub fn new(level: Level, args: fmt::Arguments<'a>, module_path: &'a str, file: &'a str, line: u32) -> Record<'a> {
                Record {
index a8c3d5621a9b343ddf4211df31506222d8f74b41..961d4f1020073f8d76553374ef0cec394e217828 100644 (file)
@@ -37,6 +37,8 @@ const MAX_BUF_SIZE: usize = 64 * 1024;
 /// buffers being written into.
 /// An impl is provided for any type that also impls std::io::Write which simply ignores size
 /// hints.
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
 pub trait Writer {
        /// Writes the given buf out. See std::io::Write::write_all for more
        fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error>;
@@ -159,6 +161,8 @@ impl<R: Read> Read for ReadTrackingReader<R> {
 }
 
 /// A trait that various rust-lightning types implement allowing them to be written out to a Writer
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
 pub trait Writeable {
        /// Writes self out to the given Writer
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error>;
@@ -186,6 +190,8 @@ impl<'a, T: Writeable> Writeable for &'a T {
 }
 
 /// A trait that various rust-lightning types implement allowing them to be read in from a Read
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
 pub trait Readable
        where Self: Sized
 {
@@ -195,6 +201,8 @@ pub trait Readable
 
 /// A trait that various higher-level rust-lightning types implement allowing them to be read in
 /// from a Read given some additional set of arguments which is required to deserialize.
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
 pub trait ReadableArgs<P>
        where Self: Sized
 {
@@ -203,6 +211,8 @@ pub trait ReadableArgs<P>
 }
 
 /// A trait that various rust-lightning types implement allowing them to (maybe) be read in from a Read
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
 pub trait MaybeReadable
        where Self: Sized
 {