From: Matt Corallo Date: Sun, 11 Sep 2022 18:38:02 +0000 (+0000) Subject: Export Onion Message structs in their respective modules X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=30a8d18ff4fdc05bf98df70dc9dd19dd4ef1db0a;p=rust-lightning 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. --- diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index a2fe88afc..74bb4f710 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -11,7 +11,7 @@ use lightning::ln::script::ShutdownScript; use lightning::util::enforcing_trait_impls::EnforcingSigner; use lightning::util::logger::Logger; use lightning::util::ser::{Readable, Writer}; -use lightning::onion_message::OnionMessenger; +use lightning::onion_message::messenger::OnionMessenger; use utils::test_logger; diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 747107c08..08ad3afcf 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -311,7 +311,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 @@ -1404,7 +1404,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 = ::read(&mut packet_reader)?; + let onion_routing_packet = ::read(&mut packet_reader)?; Ok(Self { blinding_point, onion_routing_packet, diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 6712abeb1..2a40a99db 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -25,7 +25,7 @@ use util::ser::{VecWriter, Writeable, Writer}; use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep}; use ln::wire; use ln::wire::Encode; -use onion_message::{SimpleArcOnionMessenger, SimpleRefOnionMessenger}; +use onion_message::messenger::{SimpleArcOnionMessenger, SimpleRefOnionMessenger}; use routing::gossip::{NetworkGraph, P2PGossipSync}; use util::atomic_counter::AtomicCounter; use util::crypto::sign; diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 9b4d2a549..4545cc8b5 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -12,7 +12,8 @@ use chain::keysinterface::{KeysInterface, Recipient}; use ln::features::InitFeatures; use ln::msgs::{self, OnionMessageHandler}; -use super::{BlindedRoute, Destination, OnionMessenger, SendError}; +use super::blinded_route::BlindedRoute; +use super::messenger::{Destination, OnionMessenger, SendError}; use util::enforcing_trait_impls::EnforcingSigner; use util::test_utils; diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 729fa813d..62c01e986 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -41,7 +41,8 @@ use prelude::*; /// # use bitcoin::hashes::_export::_core::time::Duration; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; /// # use lightning::chain::keysinterface::{InMemorySigner, KeysManager, KeysInterface}; -/// # use lightning::onion_message::{BlindedRoute, Destination, OnionMessenger}; +/// # use lightning::onion_message::messenger::{Destination, OnionMessenger}; +/// # use lightning::onion_message::blinded_route::BlindedRoute; /// # use lightning::util::logger::{Logger, Record}; /// # use std::sync::Arc; /// # struct FakeLogger {}; diff --git a/lightning/src/onion_message/mod.rs b/lightning/src/onion_message/mod.rs index 2e23b76ad..1830d3ba7 100644 --- a/lightning/src/onion_message/mod.rs +++ b/lightning/src/onion_message/mod.rs @@ -18,16 +18,12 @@ //! information on its usage. //! //! [offers]: -//! [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::{Destination, OnionMessenger, SendError, SimpleArcOnionMessenger, SimpleRefOnionMessenger}; -pub(crate) use self::packet::Packet;