Skip to content

Commit

Permalink
chore: use generics for response_sender and task_request in handle_re…
Browse files Browse the repository at this point in the history
…quest function
  • Loading branch information
rymnc committed Aug 26, 2024
1 parent a62694e commit e52bffc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/services/p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,20 @@ where
}
}

fn handle_request<F, R>(
fn handle_request<DbLookUpFn, ResponseSenderFn, TaskRequestFn, R>(
&mut self,
range: Range<u32>,
request_id: InboundRequestId,
response_sender: fn(Option<R>) -> ResponseMessage,
db_lookup: F,
task_request: fn(Option<R>, InboundRequestId) -> TaskRequest,
response_sender: ResponseSenderFn,
db_lookup: DbLookUpFn,
task_request: TaskRequestFn,
) -> anyhow::Result<()>
where
F: FnOnce(&V::LatestView, Range<u32>) -> anyhow::Result<Option<R>>
DbLookUpFn: Fn(&V::LatestView, Range<u32>) -> anyhow::Result<Option<R>>
+ Send
+ 'static,
ResponseSenderFn: Fn(Option<R>) -> ResponseMessage + Send + 'static,
TaskRequestFn: Fn(Option<R>, InboundRequestId) -> TaskRequest + Send + 'static,
R: Send + 'static,
{
let instant = Instant::now();
Expand Down

0 comments on commit e52bffc

Please sign in to comment.