Remove Send and Sync from core crate
authorDevrandom <c1.devrandom@niftybox.net>
Thu, 29 Apr 2021 19:07:28 +0000 (21:07 +0200)
committerDevrandom <c1.devrandom@niftybox.net>
Thu, 29 Apr 2021 19:07:28 +0000 (21:07 +0200)
12 files changed:
fuzz/src/utils/test_logger.rs
lightning-block-sync/src/poll.rs
lightning-net-tokio/src/lib.rs
lightning/src/chain/chaininterface.rs
lightning/src/chain/chainmonitor.rs
lightning/src/chain/channelmonitor.rs
lightning/src/chain/keysinterface.rs
lightning/src/chain/mod.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/msgs.rs
lightning/src/routing/network_graph.rs
lightning/src/util/logger.rs

index 36e0945f5412c987b09769637ed379ecd49130ba..5046869c0a9abe1c92a0ee57d86a3f489081d760 100644 (file)
@@ -11,7 +11,7 @@ use lightning::util::logger::{Logger, Record};
 use std::sync::{Arc, Mutex};
 use std::io::Write;
 
-pub trait Output : Clone + Sync + Send + 'static {
+pub trait Output : Clone  + 'static {
        fn locked_write(&self, data: &[u8]);
 }
 
index e769fe853c59981b355f3a26c6655af5e1d148d1..fbe803b4cf3f12aafd17b5fb7776346f9686570b 100644 (file)
@@ -160,12 +160,12 @@ impl std::ops::Deref for ValidatedBlock {
 ///
 /// Other `Poll` implementations must be built using `ChainPoller` as it provides the only means of
 /// validating chain data.
-pub struct ChainPoller<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> {
+pub struct ChainPoller<B: DerefMut<Target=T> + Sized , T: BlockSource> {
        block_source: B,
        network: Network,
 }
 
-impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> ChainPoller<B, T> {
+impl<B: DerefMut<Target=T> + Sized , T: BlockSource> ChainPoller<B, T> {
        /// Creates a new poller for the given block source.
        ///
        /// If the `network` parameter is mainnet, then the difficulty between blocks is checked for
@@ -175,7 +175,7 @@ impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> ChainPoller<B,
        }
 }
 
-impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> Poll for ChainPoller<B, T> {
+impl<B: DerefMut<Target=T> + Sized + Send + Sync, T: BlockSource> Poll for ChainPoller<B, T> {
        fn poll_chain_tip<'a>(&'a mut self, best_known_chain_tip: ValidatedBlockHeader) ->
                AsyncBlockSourceResult<'a, ChainTip>
        {
index 74da58dad3ae3a19e124579ce820e199d1b1d879..6e2a0c22eef397b18433aefa7a575cd2084ecc73 100644 (file)
 //! use std::sync::Arc;
 //!
 //! // Define concrete types for our high-level objects:
-//! type TxBroadcaster = dyn lightning::chain::chaininterface::BroadcasterInterface;
-//! type FeeEstimator = dyn lightning::chain::chaininterface::FeeEstimator;
-//! type Logger = dyn lightning::util::logger::Logger;
-//! type ChainAccess = dyn lightning::chain::Access;
-//! type ChainFilter = dyn lightning::chain::Filter;
-//! type DataPersister = dyn lightning::chain::channelmonitor::Persist<lightning::chain::keysinterface::InMemorySigner>;
+//! type TxBroadcaster = dyn lightning::chain::chaininterface::BroadcasterInterface + Send + Sync;
+//! type FeeEstimator = dyn lightning::chain::chaininterface::FeeEstimator + Send + Sync;
+//! type Logger = dyn lightning::util::logger::Logger + Send + Sync;
+//! type ChainAccess = dyn lightning::chain::Access + Send + Sync;
+//! type ChainFilter = dyn lightning::chain::Filter + Send + Sync;
+//! type DataPersister = dyn lightning::chain::channelmonitor::Persist<lightning::chain::keysinterface::InMemorySigner> + Send + Sync;
 //! type ChainMonitor = lightning::chain::chainmonitor::ChainMonitor<lightning::chain::keysinterface::InMemorySigner, Arc<ChainFilter>, Arc<TxBroadcaster>, Arc<FeeEstimator>, Arc<Logger>, Arc<DataPersister>>;
 //! type ChannelManager = Arc<lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor, TxBroadcaster, FeeEstimator, Logger>>;
 //! type PeerManager = Arc<lightning::ln::peer_handler::SimpleArcPeerManager<lightning_net_tokio::SocketDescriptor, ChainMonitor, TxBroadcaster, FeeEstimator, ChainAccess, Logger>>;
@@ -254,9 +254,9 @@ impl Connection {
 ///
 /// See the module-level documentation for how to handle the event_notify mpsc::Sender.
 pub fn setup_inbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<CMH>, Arc<RMH>, Arc<L>>>, event_notify: mpsc::Sender<()>, stream: StdTcpStream) -> impl std::future::Future<Output=()> where
-               CMH: ChannelMessageHandler + 'static,
-               RMH: RoutingMessageHandler + 'static,
-               L: Logger + 'static + ?Sized {
+               CMH: ChannelMessageHandler + 'static + Send + Sync,
+               RMH: RoutingMessageHandler + 'static + Send + Sync,
+               L: Logger + 'static + ?Sized + Send + Sync {
        let (reader, write_receiver, read_receiver, us) = Connection::new(event_notify, stream);
        #[cfg(debug_assertions)]
        let last_us = Arc::clone(&us);
@@ -296,9 +296,9 @@ pub fn setup_inbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<So
 ///
 /// See the module-level documentation for how to handle the event_notify mpsc::Sender.
 pub fn setup_outbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<CMH>, Arc<RMH>, Arc<L>>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, stream: StdTcpStream) -> impl std::future::Future<Output=()> where
-               CMH: ChannelMessageHandler + 'static,
-               RMH: RoutingMessageHandler + 'static,
-               L: Logger + 'static + ?Sized {
+               CMH: ChannelMessageHandler + 'static + Send + Sync,
+               RMH: RoutingMessageHandler + 'static + Send + Sync,
+               L: Logger + 'static + ?Sized + Send + Sync {
        let (reader, mut write_receiver, read_receiver, us) = Connection::new(event_notify, stream);
        #[cfg(debug_assertions)]
        let last_us = Arc::clone(&us);
@@ -368,9 +368,9 @@ pub fn setup_outbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<S
 ///
 /// See the module-level documentation for how to handle the event_notify mpsc::Sender.
 pub async fn connect_outbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<CMH>, Arc<RMH>, Arc<L>>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, addr: SocketAddr) -> Option<impl std::future::Future<Output=()>> where
-               CMH: ChannelMessageHandler + 'static,
-               RMH: RoutingMessageHandler + 'static,
-               L: Logger + 'static + ?Sized {
+               CMH: ChannelMessageHandler + 'static + Send + Sync,
+               RMH: RoutingMessageHandler + 'static + Send + Sync,
+               L: Logger + 'static + ?Sized + Send + Sync {
        if let Ok(Ok(stream)) = time::timeout(Duration::from_secs(10), async { TcpStream::connect(&addr).await.map(|s| s.into_std().unwrap()) }).await {
                Some(setup_outbound(peer_manager, event_notify, their_node_id, stream))
        } else { None }
index 91e604838ecbe0b4c6867184bf3146f6a18dfb65..83fee4d674d1611e82dccee1e1c674e8fb94f9aa 100644 (file)
@@ -16,7 +16,7 @@
 use bitcoin::blockdata::transaction::Transaction;
 
 /// An interface to send a transaction to the Bitcoin network.
-pub trait BroadcasterInterface: Sync + Send {
+pub trait BroadcasterInterface {
        /// Sends a transaction out to (hopefully) be mined.
        fn broadcast_transaction(&self, tx: &Transaction);
 }
@@ -37,7 +37,7 @@ pub enum ConfirmationTarget {
 ///
 /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
 /// called from inside the library in response to chain events, P2P events, or timer events).
-pub trait FeeEstimator: Sync + Send {
+pub trait FeeEstimator {
        /// Gets estimated satoshis of fee required per 1000 Weight-Units.
        ///
        /// Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
index 5055305d3c5d52bd9e01cc02d0934c79104f0b37..f708bfe9b6110e543e1a7d6aad63a34fcd7e08ed 100644 (file)
@@ -214,7 +214,7 @@ where
        }
 }
 
-impl<ChannelSigner: Sign, C: Deref + Sync + Send, T: Deref + Sync + Send, F: Deref + Sync + Send, L: Deref + Sync + Send, P: Deref + Sync + Send>
+impl<ChannelSigner: Sign, C: Deref , T: Deref , F: Deref , L: Deref , P: Deref >
 chain::Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P>
 where C::Target: chain::Filter,
            T::Target: BroadcasterInterface,
index f0b23c08619632c4ab14d45f5322d51cc017c38d..c68ee39bb47a9c1b01b7ec72c52604f356267962 100644 (file)
@@ -2663,7 +2663,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
 /// transaction and losing money. This is a risk because previous channel states
 /// are toxic, so it's important that whatever channel state is persisted is
 /// kept up-to-date.
-pub trait Persist<ChannelSigner: Sign>: Send + Sync {
+pub trait Persist<ChannelSigner: Sign> {
        /// Persist a new channel's data. The data can be stored any way you want, but
        /// the identifier provided by Rust-Lightning is the channel's outpoint (and
        /// it is up to you to maintain a correct mapping between the outpoint and the
index 89306c6e3c2f1ca34c9a3a8d43f4908c5baabb4d..02ee9b5f563b11ab095b592d0b68d866506efa73 100644 (file)
@@ -226,7 +226,7 @@ impl Readable for SpendableOutputDescriptor {
 /// of LN security model, orthogonal of key management issues.
 // TODO: We should remove Clone by instead requesting a new Sign copy when we create
 // ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
-pub trait BaseSign : Send {
+pub trait BaseSign {
        /// Gets the per-commitment point for a specific commitment number
        ///
        /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
@@ -353,7 +353,7 @@ pub trait Sign: BaseSign + Writeable + Clone {
 }
 
 /// A trait to describe an object which can get user secrets and key material.
-pub trait KeysInterface: Send + Sync {
+pub trait KeysInterface {
        /// A type which implements Sign which will be returned by get_channel_signer.
        type Signer : Sign;
 
index 7f99467642add8ade3a378671a4dad0fadd51598..2d62016e9ec53e35b771efb5bdce8fde860941fe 100644 (file)
@@ -36,7 +36,7 @@ pub enum AccessError {
 
 /// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
 /// UTXOs.
-pub trait Access: Send + Sync {
+pub trait Access {
        /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
        /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output
        /// is unknown.
@@ -161,7 +161,7 @@ pub trait Confirm {
 /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
 /// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
 /// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure
-pub trait Watch<ChannelSigner: Sign>: Send + Sync {
+pub trait Watch<ChannelSigner: Sign> {
        /// Watches a channel identified by `funding_txo` using `monitor`.
        ///
        /// Implementations are responsible for watching the chain for the funding transaction along
@@ -207,7 +207,7 @@ pub trait Watch<ChannelSigner: Sign>: Send + Sync {
 /// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
 /// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
 /// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
-pub trait Filter: Send + Sync {
+pub trait Filter {
        /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
        /// a spending condition.
        fn register_tx(&self, txid: &Txid, script_pubkey: &Script);
index 31529343d56d22b646ab37c44f0f3639be7d2dec..451bf8be4a1cf02a74e4daa189658e59d8e05d98 100644 (file)
@@ -68,7 +68,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
 use std::time::Duration;
 #[cfg(any(test, feature = "allow_wallclock_use"))]
 use std::time::Instant;
-use std::marker::{Sync, Send};
 use std::ops::Deref;
 use bitcoin::hashes::hex::ToHex;
 
@@ -3764,7 +3763,7 @@ where
        }
 }
 
-impl<Signer: Sign, M: Deref + Sync + Send, T: Deref + Sync + Send, K: Deref + Sync + Send, F: Deref + Sync + Send, L: Deref + Sync + Send>
+impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
        ChannelMessageHandler for ChannelManager<Signer, M, T, K, F, L>
        where M::Target: chain::Watch<Signer>,
         T::Target: BroadcasterInterface,
index 8a7713dc74ec9ceea3e427aab41995cc7fa8e995..5cb72842a85faa3ee557a51563a68d1665cd1b36 100644 (file)
@@ -744,7 +744,7 @@ pub enum OptionalField<T> {
 ///
 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
 /// they MUST NOT be called in parallel when the two calls have the same their_node_id.
-pub trait ChannelMessageHandler : MessageSendEventsProvider + Send + Sync {
+pub trait ChannelMessageHandler : MessageSendEventsProvider {
        //Channel init:
        /// Handle an incoming open_channel message from the given peer.
        fn handle_open_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &OpenChannel);
@@ -811,7 +811,7 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider + Send + Sync {
 /// For `gossip_queries` messages there are potential DoS vectors when handling
 /// inbound queries. Implementors using an on-disk network graph should be aware of
 /// repeated disk I/O for queries accessing different parts of the network graph.
-pub trait RoutingMessageHandler : Send + Sync + MessageSendEventsProvider {
+pub trait RoutingMessageHandler : MessageSendEventsProvider {
        /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
        /// false or returning an Err otherwise.
        fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
index 04e4eb14770aaaf7aed188fbee571fa7e32946b7..765a3430f579c033b31b674ae6071ab94b125330 100644 (file)
@@ -152,7 +152,7 @@ macro_rules! secp_verify_sig {
        };
 }
 
-impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
+impl<C: Deref , L: Deref > RoutingMessageHandler for NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
        fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
                self.network_graph.write().unwrap().update_node_from_announcement(msg, &self.secp_ctx)?;
                Ok(msg.contents.excess_data.len() <=  MAX_EXCESS_BYTES_FOR_RELAY &&
index acd6d323e8f319e9b3c84550ab099d2258f486cb..2cf0f13633661a5ae6eed6ed180ddc3978fdaa26 100644 (file)
@@ -117,7 +117,7 @@ impl<'a> Record<'a> {
 }
 
 /// A trait encapsulating the operations required of a logger
-pub trait Logger: Sync + Send {
+pub trait Logger {
        /// Logs the `Record`
        fn log(&self, record: &Record);
 }