Skip to content

Commit ec35fe6

Browse files
committed
Remove Send and Sync from core crate
1 parent cb0b4bf commit ec35fe6

File tree

12 files changed

+33
-34
lines changed

12 files changed

+33
-34
lines changed

fuzz/src/utils/test_logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use lightning::util::logger::{Logger, Record};
1111
use std::sync::{Arc, Mutex};
1212
use std::io::Write;
1313

14-
pub trait Output : Clone + Sync + Send + 'static {
14+
pub trait Output : Clone + 'static {
1515
fn locked_write(&self, data: &[u8]);
1616
}
1717

lightning-block-sync/src/poll.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ impl std::ops::Deref for ValidatedBlock {
160160
///
161161
/// Other `Poll` implementations must be built using `ChainPoller` as it provides the only means of
162162
/// validating chain data.
163-
pub struct ChainPoller<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> {
163+
pub struct ChainPoller<B: DerefMut<Target=T> + Sized , T: BlockSource> {
164164
block_source: B,
165165
network: Network,
166166
}
167167

168-
impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> ChainPoller<B, T> {
168+
impl<B: DerefMut<Target=T> + Sized , T: BlockSource> ChainPoller<B, T> {
169169
/// Creates a new poller for the given block source.
170170
///
171171
/// 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,
175175
}
176176
}
177177

178-
impl<B: DerefMut<Target=T> + Sized + Sync + Send, T: BlockSource> Poll for ChainPoller<B, T> {
178+
impl<B: DerefMut<Target=T> + Sized + Send + Sync, T: BlockSource> Poll for ChainPoller<B, T> {
179179
fn poll_chain_tip<'a>(&'a mut self, best_known_chain_tip: ValidatedBlockHeader) ->
180180
AsyncBlockSourceResult<'a, ChainTip>
181181
{

lightning-net-tokio/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
//! use std::sync::Arc;
3232
//!
3333
//! // Define concrete types for our high-level objects:
34-
//! type TxBroadcaster = dyn lightning::chain::chaininterface::BroadcasterInterface;
35-
//! type FeeEstimator = dyn lightning::chain::chaininterface::FeeEstimator;
36-
//! type Logger = dyn lightning::util::logger::Logger;
37-
//! type ChainAccess = dyn lightning::chain::Access;
38-
//! type ChainFilter = dyn lightning::chain::Filter;
39-
//! type DataPersister = dyn lightning::chain::channelmonitor::Persist<lightning::chain::keysinterface::InMemorySigner>;
34+
//! type TxBroadcaster = dyn lightning::chain::chaininterface::BroadcasterInterface + Send + Sync;
35+
//! type FeeEstimator = dyn lightning::chain::chaininterface::FeeEstimator + Send + Sync;
36+
//! type Logger = dyn lightning::util::logger::Logger + Send + Sync;
37+
//! type ChainAccess = dyn lightning::chain::Access + Send + Sync;
38+
//! type ChainFilter = dyn lightning::chain::Filter + Send + Sync;
39+
//! type DataPersister = dyn lightning::chain::channelmonitor::Persist<lightning::chain::keysinterface::InMemorySigner> + Send + Sync;
4040
//! type ChainMonitor = lightning::chain::chainmonitor::ChainMonitor<lightning::chain::keysinterface::InMemorySigner, Arc<ChainFilter>, Arc<TxBroadcaster>, Arc<FeeEstimator>, Arc<Logger>, Arc<DataPersister>>;
4141
//! type ChannelManager = Arc<lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor, TxBroadcaster, FeeEstimator, Logger>>;
4242
//! type PeerManager = Arc<lightning::ln::peer_handler::SimpleArcPeerManager<lightning_net_tokio::SocketDescriptor, ChainMonitor, TxBroadcaster, FeeEstimator, ChainAccess, Logger>>;
@@ -254,9 +254,9 @@ impl Connection {
254254
///
255255
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
256256
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
257-
CMH: ChannelMessageHandler + 'static,
258-
RMH: RoutingMessageHandler + 'static,
259-
L: Logger + 'static + ?Sized {
257+
CMH: ChannelMessageHandler + 'static + Send + Sync,
258+
RMH: RoutingMessageHandler + 'static + Send + Sync,
259+
L: Logger + 'static + ?Sized + Send + Sync {
260260
let (reader, write_receiver, read_receiver, us) = Connection::new(event_notify, stream);
261261
#[cfg(debug_assertions)]
262262
let last_us = Arc::clone(&us);
@@ -296,9 +296,9 @@ pub fn setup_inbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<So
296296
///
297297
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
298298
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
299-
CMH: ChannelMessageHandler + 'static,
300-
RMH: RoutingMessageHandler + 'static,
301-
L: Logger + 'static + ?Sized {
299+
CMH: ChannelMessageHandler + 'static + Send + Sync,
300+
RMH: RoutingMessageHandler + 'static + Send + Sync,
301+
L: Logger + 'static + ?Sized + Send + Sync {
302302
let (reader, mut write_receiver, read_receiver, us) = Connection::new(event_notify, stream);
303303
#[cfg(debug_assertions)]
304304
let last_us = Arc::clone(&us);
@@ -368,9 +368,9 @@ pub fn setup_outbound<CMH, RMH, L>(peer_manager: Arc<peer_handler::PeerManager<S
368368
///
369369
/// See the module-level documentation for how to handle the event_notify mpsc::Sender.
370370
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
371-
CMH: ChannelMessageHandler + 'static,
372-
RMH: RoutingMessageHandler + 'static,
373-
L: Logger + 'static + ?Sized {
371+
CMH: ChannelMessageHandler + 'static + Send + Sync,
372+
RMH: RoutingMessageHandler + 'static + Send + Sync,
373+
L: Logger + 'static + ?Sized + Send + Sync {
374374
if let Ok(Ok(stream)) = time::timeout(Duration::from_secs(10), async { TcpStream::connect(&addr).await.map(|s| s.into_std().unwrap()) }).await {
375375
Some(setup_outbound(peer_manager, event_notify, their_node_id, stream))
376376
} else { None }

lightning/src/chain/chaininterface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use bitcoin::blockdata::transaction::Transaction;
1717

1818
/// An interface to send a transaction to the Bitcoin network.
19-
pub trait BroadcasterInterface: Sync + Send {
19+
pub trait BroadcasterInterface {
2020
/// Sends a transaction out to (hopefully) be mined.
2121
fn broadcast_transaction(&self, tx: &Transaction);
2222
}
@@ -37,7 +37,7 @@ pub enum ConfirmationTarget {
3737
///
3838
/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
3939
/// called from inside the library in response to chain events, P2P events, or timer events).
40-
pub trait FeeEstimator: Sync + Send {
40+
pub trait FeeEstimator {
4141
/// Gets estimated satoshis of fee required per 1000 Weight-Units.
4242
///
4343
/// Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ where
214214
}
215215
}
216216

217-
impl<ChannelSigner: Sign, C: Deref + Sync + Send, T: Deref + Sync + Send, F: Deref + Sync + Send, L: Deref + Sync + Send, P: Deref + Sync + Send>
217+
impl<ChannelSigner: Sign, C: Deref , T: Deref , F: Deref , L: Deref , P: Deref >
218218
chain::Watch<ChannelSigner> for ChainMonitor<ChannelSigner, C, T, F, L, P>
219219
where C::Target: chain::Filter,
220220
T::Target: BroadcasterInterface,

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26632663
/// transaction and losing money. This is a risk because previous channel states
26642664
/// are toxic, so it's important that whatever channel state is persisted is
26652665
/// kept up-to-date.
2666-
pub trait Persist<ChannelSigner: Sign>: Send + Sync {
2666+
pub trait Persist<ChannelSigner: Sign> {
26672667
/// Persist a new channel's data. The data can be stored any way you want, but
26682668
/// the identifier provided by Rust-Lightning is the channel's outpoint (and
26692669
/// it is up to you to maintain a correct mapping between the outpoint and the

lightning/src/chain/keysinterface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Readable for SpendableOutputDescriptor {
226226
/// of LN security model, orthogonal of key management issues.
227227
// TODO: We should remove Clone by instead requesting a new Sign copy when we create
228228
// ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
229-
pub trait BaseSign : Send {
229+
pub trait BaseSign {
230230
/// Gets the per-commitment point for a specific commitment number
231231
///
232232
/// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
@@ -353,7 +353,7 @@ pub trait Sign: BaseSign + Writeable + Clone {
353353
}
354354

355355
/// A trait to describe an object which can get user secrets and key material.
356-
pub trait KeysInterface: Send + Sync {
356+
pub trait KeysInterface {
357357
/// A type which implements Sign which will be returned by get_channel_signer.
358358
type Signer : Sign;
359359

lightning/src/chain/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum AccessError {
3636

3737
/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
3838
/// UTXOs.
39-
pub trait Access: Send + Sync {
39+
pub trait Access {
4040
/// Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
4141
/// Returns an error if `genesis_hash` is for a different chain or if such a transaction output
4242
/// is unknown.
@@ -161,7 +161,7 @@ pub trait Confirm {
161161
/// [`ChannelMonitor`]: channelmonitor::ChannelMonitor
162162
/// [`ChannelMonitorUpdateErr`]: channelmonitor::ChannelMonitorUpdateErr
163163
/// [`PermanentFailure`]: channelmonitor::ChannelMonitorUpdateErr::PermanentFailure
164-
pub trait Watch<ChannelSigner: Sign>: Send + Sync {
164+
pub trait Watch<ChannelSigner: Sign> {
165165
/// Watches a channel identified by `funding_txo` using `monitor`.
166166
///
167167
/// Implementations are responsible for watching the chain for the funding transaction along
@@ -207,7 +207,7 @@ pub trait Watch<ChannelSigner: Sign>: Send + Sync {
207207
/// [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
208208
/// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
209209
/// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
210-
pub trait Filter: Send + Sync {
210+
pub trait Filter {
211211
/// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
212212
/// a spending condition.
213213
fn register_tx(&self, txid: &Txid, script_pubkey: &Script);

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
6868
use std::time::Duration;
6969
#[cfg(any(test, feature = "allow_wallclock_use"))]
7070
use std::time::Instant;
71-
use std::marker::{Sync, Send};
7271
use std::ops::Deref;
7372
use bitcoin::hashes::hex::ToHex;
7473

@@ -3764,7 +3763,7 @@ where
37643763
}
37653764
}
37663765

3767-
impl<Signer: Sign, M: Deref + Sync + Send, T: Deref + Sync + Send, K: Deref + Sync + Send, F: Deref + Sync + Send, L: Deref + Sync + Send>
3766+
impl<Signer: Sign, M: Deref , T: Deref , K: Deref , F: Deref , L: Deref >
37683767
ChannelMessageHandler for ChannelManager<Signer, M, T, K, F, L>
37693768
where M::Target: chain::Watch<Signer>,
37703769
T::Target: BroadcasterInterface,

lightning/src/ln/msgs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pub enum OptionalField<T> {
744744
///
745745
/// Messages MAY be called in parallel when they originate from different their_node_ids, however
746746
/// they MUST NOT be called in parallel when the two calls have the same their_node_id.
747-
pub trait ChannelMessageHandler : MessageSendEventsProvider + Send + Sync {
747+
pub trait ChannelMessageHandler : MessageSendEventsProvider {
748748
//Channel init:
749749
/// Handle an incoming open_channel message from the given peer.
750750
fn handle_open_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &OpenChannel);
@@ -811,7 +811,7 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider + Send + Sync {
811811
/// For `gossip_queries` messages there are potential DoS vectors when handling
812812
/// inbound queries. Implementors using an on-disk network graph should be aware of
813813
/// repeated disk I/O for queries accessing different parts of the network graph.
814-
pub trait RoutingMessageHandler : Send + Sync + MessageSendEventsProvider {
814+
pub trait RoutingMessageHandler : MessageSendEventsProvider {
815815
/// Handle an incoming node_announcement message, returning true if it should be forwarded on,
816816
/// false or returning an Err otherwise.
817817
fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, LightningError>;

lightning/src/routing/network_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ macro_rules! secp_verify_sig {
152152
};
153153
}
154154

155-
impl<C: Deref + Sync + Send, L: Deref + Sync + Send> RoutingMessageHandler for NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
155+
impl<C: Deref , L: Deref > RoutingMessageHandler for NetGraphMsgHandler<C, L> where C::Target: chain::Access, L::Target: Logger {
156156
fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
157157
self.network_graph.write().unwrap().update_node_from_announcement(msg, &self.secp_ctx)?;
158158
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&

lightning/src/util/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> Record<'a> {
117117
}
118118

119119
/// A trait encapsulating the operations required of a logger
120-
pub trait Logger: Sync + Send {
120+
pub trait Logger {
121121
/// Logs the `Record`
122122
fn log(&self, record: &Record);
123123
}

0 commit comments

Comments
 (0)