Skip to content

Commit a9e9f4e

Browse files
authored
refactor: drop trait bounds from structs (#4251)
1 parent c5faeb0 commit a9e9f4e

5 files changed

Lines changed: 15 additions & 30 deletions

File tree

crates/node/src/assets.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use std::sync::{Arc, Mutex};
3737
/// NB: Assets may be reordered by these operations. No guarantees are made on the order in which
3838
/// assets are taken or discarded from the queue.
3939
///
40-
struct ColdQueue<T, CondVal: Default + Eq> {
40+
struct ColdQueue<T, CondVal> {
4141
cold_ready: usize,
4242
cold_available: usize,
4343
cold_queue: VecDeque<(UniqueId, T)>,
@@ -227,10 +227,7 @@ enum ColdQueueAddIfNotSatisfiedResult<T> {
227227
Enqueued,
228228
}
229229

230-
pub struct DoubleQueue<T, CondVal: Default + Eq>
231-
where
232-
T: Send + 'static,
233-
{
230+
pub struct DoubleQueue<T, CondVal> {
234231
hot_sender: flume::Sender<(UniqueId, T)>,
235232
hot_receiver: flume::Receiver<(UniqueId, T)>,
236233
cold_queue: Arc<Mutex<ColdQueue<T, CondVal>>>,
@@ -432,10 +429,7 @@ where
432429
///
433430
/// As a passive participant of a computation, unowned assets are taken using
434431
/// `take_unowned`.
435-
pub struct DistributedAssetStorage<T>
436-
where
437-
T: Serialize + DeserializeOwned + Send + 'static,
438-
{
432+
pub struct DistributedAssetStorage<T> {
439433
db: Arc<SecretDB>,
440434
col: DBCol,
441435
/// Byte prefix prepended to every key written under `col`. Empty [`Vec`] means

crates/node/src/network/conn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct ConnectionVersion {
2323
/// and the weak ptr points to nothing. So version() returns 1, meaning that
2424
/// when to send or receive anything, we would wait until the first connection
2525
/// is established.
26-
pub struct ConnectionWithVersion<T: Send + Sync + 'static> {
26+
pub struct ConnectionWithVersion<T> {
2727
pub connection: Weak<T>,
2828
version: usize,
2929
}
@@ -68,7 +68,7 @@ where
6868

6969
/// Struct to track bidirectional connectivity between two nodes.
7070
/// A node has one NodeConnectivity for each other node in the network.
71-
pub struct NodeConnectivity<I: Send + Sync + 'static, O: Send + Sync + 'static> {
71+
pub struct NodeConnectivity<I, O> {
7272
outgoing_sender: tokio::sync::watch::Sender<ConnectionWithVersion<I>>,
7373
outgoing_receiver: tokio::sync::watch::Receiver<ConnectionWithVersion<I>>,
7474
incoming_sender: tokio::sync::watch::Sender<ConnectionWithVersion<O>>,
@@ -284,7 +284,7 @@ where
284284
}
285285

286286
/// Convenient collection of multiple NodeConnectivity objects.
287-
pub struct AllNodeConnectivities<I: Send + Sync + 'static, O: Send + Sync + 'static> {
287+
pub struct AllNodeConnectivities<I, O> {
288288
connectivities: HashMap<ParticipantId, Arc<NodeConnectivity<I, O>>>,
289289
}
290290

crates/node/src/providers/ecdsa_common.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ impl<P> HasParticipants for PresignOutputWithParticipants<P> {
3737

3838
/// Per-domain presignature store, keyed on disk by `domain_id` under [`crate::db::DBCol::Presignature`].
3939
#[derive(derive_more::Deref)]
40-
pub struct PresignatureStorage<P>(DistributedAssetStorage<PresignOutputWithParticipants<P>>)
41-
where
42-
P: Serialize + DeserializeOwned + Send + 'static;
40+
pub struct PresignatureStorage<P>(DistributedAssetStorage<PresignOutputWithParticipants<P>>);
4341

4442
impl<P> PresignatureStorage<P>
4543
where
@@ -69,10 +67,7 @@ where
6967

7068
/// A domain's [`DomainKeyshare`] material plus a presignature store, which is runtime state the
7169
/// coordinator can't provide and so is built here.
72-
pub struct EcdsaKeyshare<P>
73-
where
74-
P: Serialize + DeserializeOwned + Send + 'static,
75-
{
70+
pub struct EcdsaKeyshare<P> {
7671
pub keygen_output: KeygenOutput,
7772
pub presignature_store: Arc<PresignatureStorage<P>>,
7873
pub reconstruction_threshold: ReconstructionThreshold,

crates/node/src/requests/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const NUM_COMPLETED_REQUESTS_TO_KEEP: usize = 100;
1515

1616
/// A completed request, kept for surfacing on the queue's debug
1717
/// endpoints (`/debug/signatures`, `/debug/ckds`).
18-
pub(super) struct CompletedRequest<RequestType: Request, ChainRespondArgsType: ChainRespondArgs> {
18+
pub(super) struct CompletedRequest<RequestType, ChainRespondArgsType> {
1919
pub request: RequestType,
2020
pub progress: Arc<Mutex<ComputationProgress<ChainRespondArgsType>>>,
2121
pub indexed_block_height: BlockHeight,
@@ -27,7 +27,7 @@ pub(super) struct CompletedRequest<RequestType: Request, ChainRespondArgsType: C
2727
/// A buffer of completed requests, surfaced on the queue's debug
2828
/// endpoints (`/debug/signatures`, `/debug/ckds`). Keeps the most
2929
/// recent `NUM_COMPLETED_REQUESTS_TO_KEEP` requests.
30-
pub(super) struct CompletedRequests<RequestType: Request, ChainRespondArgsType: ChainRespondArgs> {
30+
pub(super) struct CompletedRequests<RequestType, ChainRespondArgsType> {
3131
/// Min-heap, so that the oldest requests are at the front to be removed.
3232
requests: BinaryHeap<CompletedRequest<RequestType, ChainRespondArgsType>>,
3333
}

crates/node/src/requests/queue.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ impl<RequestType> RefineEligibleLeaders<RequestType> for NoRefinement {
7979
/// the queue will adapt to the new state and attempt to find new leaders for the requests.
8080
/// - If a request is too old so that it would have timed out on chain, it will be
8181
/// discarded.
82-
pub struct PendingRequests<
83-
RequestType: Request,
84-
ChainRespondArgsType: ChainRespondArgs,
85-
Refiner: RefineEligibleLeaders<RequestType> = NoRefinement,
86-
> {
82+
pub struct PendingRequests<RequestType, ChainRespondArgsType, Refiner = NoRefinement> {
8783
pub(super) clock: near_time::Clock,
8884

8985
/// All participants in the network, regardless of whether they are online.
@@ -181,7 +177,7 @@ enum AggregateResponseStatus {
181177
}
182178

183179
/// The state of a single request in the queue.
184-
pub(super) struct QueuedRequest<RequestType: Request, ChainRespondArgsType: ChainRespondArgs> {
180+
pub(super) struct QueuedRequest<RequestType, ChainRespondArgsType> {
185181
pub request: RequestType,
186182

187183
/// Finality status of the block the request was included in.
@@ -216,15 +212,15 @@ pub(super) struct QueuedRequest<RequestType: Request, ChainRespondArgsType: Chai
216212
}
217213

218214
/// Struct given to the response generation code.
219-
pub struct GenerationAttempt<RequestType: Request, ChainRespondArgsType: ChainRespondArgs> {
215+
pub struct GenerationAttempt<RequestType, ChainRespondArgsType> {
220216
/// The request we should attempt to generate for.
221217
pub request: RequestType,
222218
/// The progress of the computation. Writable and survives multiple attempts.
223219
pub computation_progress: Arc<Mutex<ComputationProgress<ChainRespondArgsType>>>,
224220
}
225221

226222
/// Progress that persists across attempts.
227-
pub struct ComputationProgress<ChainRespondArgsType: ChainRespondArgs> {
223+
pub struct ComputationProgress<ChainRespondArgsType> {
228224
/// Number of attempts that have been made to generate the request.
229225
/// This is used to abort after too many attempts.
230226
pub attempts: u64,
@@ -442,7 +438,7 @@ impl<RequestType: Request + Clone, ChainRespondArgsType: ChainRespondArgs>
442438
}
443439
}
444440

445-
enum RequestStatus<RequestType: Request, ChainRespondArgsType: ChainRespondArgs> {
441+
enum RequestStatus<RequestType, ChainRespondArgsType> {
446442
Drop(DropReason),
447443
Wait(&'static str),
448444
Attempt(Arc<GenerationAttempt<RequestType, ChainRespondArgsType>>),

0 commit comments

Comments
 (0)