]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Export Onion Message structs in their respective modules
authorMatt Corallo <git@bluematt.me>
Thu, 27 Oct 2022 01:28:05 +0000 (01:28 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 27 Oct 2022 20:15:06 +0000 (20:15 +0000)
Re-exports in Rust make `use` statements a little shorter, but for
otherwise don't materially change a crate's API. Sadly, the C
bindings generator currently can't figure out re-exports, but it
also exports everything into one global namespace, so it doesn't
matter much anyway.

fuzz/src/onion_message.rs
lightning-rapid-gossip-sync/src/lib.rs
lightning/src/ln/msgs.rs
lightning/src/ln/peer_handler.rs
lightning/src/onion_message/functional_tests.rs
lightning/src/onion_message/messenger.rs
lightning/src/onion_message/mod.rs

index 8fa6e4231be499a0e1ba989b68ed4c0c7dcc8e0c..6f5c945c194767eb2adc54bc85f70a79870c7bbb 100644 (file)
@@ -11,7 +11,8 @@ use lightning::ln::script::ShutdownScript;
 use lightning::util::enforcing_trait_impls::EnforcingSigner;
 use lightning::util::logger::Logger;
 use lightning::util::ser::{Readable, Writeable, Writer};
-use lightning::onion_message::{CustomOnionMessageContents, CustomOnionMessageHandler, OnionMessenger};
+use lightning::onion_message::packet::CustomOnionMessageContents;
+use lightning::onion_message::messenger::{OnionMessenger, CustomOnionMessageHandler};
 
 use crate::utils::test_logger;
 
index 06ce7eb2075574df38c2b9cbf44813235e1fba1c..b347f69c1feea67f430359c4d0db89da716991a1 100644 (file)
@@ -79,10 +79,10 @@ use lightning::io;
 use lightning::routing::gossip::NetworkGraph;
 use lightning::util::logger::Logger;
 
-pub use crate::error::GraphSyncError;
+use crate::error::GraphSyncError;
 
 /// Error types that these functions can return
-mod error;
+pub mod error;
 
 /// Core functionality of this crate
 mod processing;
index 8b5a6ac6fd24e32f4ba2dcc25c3715eb86531b30..f6bfc7995c59f4c36eb072bf96318dd537f5e525 100644 (file)
@@ -310,7 +310,7 @@ pub struct UpdateAddHTLC {
 pub struct OnionMessage {
        /// Used in decrypting the onion packet's payload.
        pub blinding_point: PublicKey,
-       pub(crate) onion_routing_packet: onion_message::Packet,
+       pub(crate) onion_routing_packet: onion_message::packet::Packet,
 }
 
 /// An update_fulfill_htlc message to be sent or received from a peer
@@ -1422,7 +1422,7 @@ impl Readable for OnionMessage {
                let blinding_point: PublicKey = Readable::read(r)?;
                let len: u16 = Readable::read(r)?;
                let mut packet_reader = FixedLengthReader::new(r, len as u64);
-               let onion_routing_packet: onion_message::Packet = <onion_message::Packet as LengthReadable>::read(&mut packet_reader)?;
+               let onion_routing_packet = <onion_message::packet::Packet as LengthReadable>::read(&mut packet_reader)?;
                Ok(Self {
                        blinding_point,
                        onion_routing_packet,
index 351f5142604ef2bb6df0cf528720148febcb59fc..a65ed06367785f16c26c65b06929a13c6a0538b4 100644 (file)
@@ -25,7 +25,8 @@ use crate::util::ser::{VecWriter, Writeable, Writer};
 use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
 use crate::ln::wire;
 use crate::ln::wire::Encode;
-use crate::onion_message::{CustomOnionMessageContents, CustomOnionMessageHandler, SimpleArcOnionMessenger, SimpleRefOnionMessenger};
+use crate::onion_message::messenger::{CustomOnionMessageHandler, SimpleArcOnionMessenger, SimpleRefOnionMessenger};
+use crate::onion_message::packet::CustomOnionMessageContents;
 use crate::routing::gossip::{NetworkGraph, P2PGossipSync};
 use crate::util::atomic_counter::AtomicCounter;
 use crate::util::crypto::sign;
index d1e892de016c35ef48b74c9ff844c2ebdb9ea526..efa6507bd325245185d67e891f0db61a133d3faf 100644 (file)
@@ -12,7 +12,9 @@
 use crate::chain::keysinterface::{KeysInterface, Recipient};
 use crate::ln::features::InitFeatures;
 use crate::ln::msgs::{self, DecodeError, OnionMessageHandler};
-use super::{BlindedRoute, CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError};
+use super::blinded_route::BlindedRoute;
+use super::messenger::{CustomOnionMessageHandler, Destination, OnionMessenger, SendError};
+use super::packet::{CustomOnionMessageContents, OnionMessageContents};
 use crate::util::enforcing_trait_impls::EnforcingSigner;
 use crate::util::ser::{ Writeable, Writer};
 use crate::util::test_utils;
index a80715e16f092362473b16b7dd1fb5fb5d251346..261f59c445b2ba88357a5fc63c0f179c9a793b96 100644 (file)
@@ -21,7 +21,7 @@ use crate::ln::msgs::{self, OnionMessageHandler};
 use crate::ln::onion_utils;
 use crate::ln::peer_handler::IgnoringMessageHandler;
 use super::blinded_route::{BlindedRoute, ForwardTlvs, ReceiveTlvs};
-pub use super::packet::{CustomOnionMessageContents, OnionMessageContents};
+use super::packet::{CustomOnionMessageContents, OnionMessageContents};
 use super::packet::{BIG_PACKET_HOP_DATA_LEN, ForwardControlTlvs, Packet, Payload, ReceiveControlTlvs, SMALL_PACKET_HOP_DATA_LEN};
 use super::utils;
 use crate::util::events::OnionMessageProvider;
@@ -46,7 +46,9 @@ use crate::prelude::*;
 /// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface};
 /// # use lightning::ln::msgs::DecodeError;
 /// # use lightning::ln::peer_handler::IgnoringMessageHandler;
-/// # use lightning::onion_message::{BlindedRoute, CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger};
+/// # use lightning::onion_message::messenger::{Destination, OnionMessenger};
+/// # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents};
+/// # use lightning::onion_message::blinded_route::BlindedRoute;
 /// # use lightning::util::logger::{Logger, Record};
 /// # use lightning::util::ser::{Writeable, Writer};
 /// # use lightning::io;
index 3c522e30c51bf367c25311b6987418f3fe802931..1830d3ba7376bb01bbe0f8f0c2e17900e2d64e6a 100644 (file)
 //! information on its usage.
 //!
 //! [offers]: <https://github.com/lightning/bolts/pull/798>
-//! [blinded routes]: crate::onion_message::BlindedRoute
+//! [blinded routes]: crate::onion_message::blinded_route::BlindedRoute
+//! [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
 
-mod blinded_route;
-mod messenger;
-mod packet;
+pub mod blinded_route;
+pub mod messenger;
+pub mod packet;
 mod utils;
 #[cfg(test)]
 mod functional_tests;
-
-// Re-export structs so they can be imported with just the `onion_message::` module prefix.
-pub use self::blinded_route::{BlindedRoute, BlindedHop};
-pub use self::messenger::{CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger};
-pub(crate) use self::packet::Packet;