From 3194d833b609e72b0b3cf0bcf988d37eadc75c74 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 19 Dec 2022 21:38:45 +0000 Subject: [PATCH] Export Onion Message structs in their respective modules 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 | 3 ++- lightning-rapid-gossip-sync/src/lib.rs | 4 ++-- lightning/src/onion_message/messenger.rs | 5 +++-- lightning/src/onion_message/mod.rs | 14 +++++++------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index b1f8fc336..0e0ea25b4 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -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; diff --git a/lightning-rapid-gossip-sync/src/lib.rs b/lightning-rapid-gossip-sync/src/lib.rs index 06ce7eb20..b347f69c1 100644 --- a/lightning-rapid-gossip-sync/src/lib.rs +++ b/lightning-rapid-gossip-sync/src/lib.rs @@ -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; diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 269b5f8cb..3ee9d8fc4 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -21,7 +21,7 @@ use crate::ln::msgs::{self, OnionMessageHandler}; use crate::ln::onion_utils; use crate::ln::peer_handler::IgnoringMessageHandler; use super::blinded_path::{BlindedPath, 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,8 @@ 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::{BlindedPath, CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger}; +/// # use lightning::onion_message::blinded_path::BlindedPath; +/// # use lightning::onion_message::messenger::{CustomOnionMessageContents, Destination, OnionMessageContents, OnionMessenger}; /// # use lightning::util::logger::{Logger, Record}; /// # use lightning::util::ser::{Writeable, Writer}; /// # use lightning::io; diff --git a/lightning/src/onion_message/mod.rs b/lightning/src/onion_message/mod.rs index e735b428e..7a2ee12d0 100644 --- a/lightning/src/onion_message/mod.rs +++ b/lightning/src/onion_message/mod.rs @@ -20,14 +20,14 @@ //! [offers]: //! [blinded paths]: crate::onion_message::BlindedPath -mod blinded_path; -mod messenger; -mod packet; +pub mod blinded_path; +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_path::{BlindedPath, BlindedHop}; -pub use self::messenger::{CustomOnionMessageContents, CustomOnionMessageHandler, Destination, OnionMessageContents, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger}; -pub(crate) use self::packet::Packet; + +pub(crate) use self::blinded_path::{BlindedPath, BlindedHop}; +pub(crate) use self::messenger::{CustomOnionMessageHandler, Destination, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger}; +pub(crate) use self::packet::{Packet, CustomOnionMessageContents, OnionMessageContents}; -- 2.39.5