Skip to content

Commit

Permalink
remove spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Oct 2, 2024
1 parent 0bdb7f9 commit ffecd51
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/pow/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Prover for K2powService {
);
let semaphore = self.semaphore.clone();

let task = tokio::spawn(async move {
let task = async move {
let _permit = semaphore.acquire().await.unwrap();
let client = reqwest::Client::new();

Expand Down Expand Up @@ -98,20 +98,14 @@ impl Prover for K2powService {
};
return res;
}
});
};
tasks.push(task);
});

match future::join_all(tasks)
future::join_all(tasks)
.await
.into_iter()
.collect::<Result<Vec<Result<(u32, u64), Error>>, tokio::task::JoinError>>()
{
Ok(results) => results
.into_iter()
.collect::<Result<Vec<(u32, u64)>, Error>>(),
Err(e) => Err(Error::Internal(e.into())),
}
.collect::<Result<Vec<(u32, u64)>, Error>>()
})
}

Expand Down

0 comments on commit ffecd51

Please sign in to comment.