cuprate_txpool/service/
free.rs1use std::sync::Arc;
2
3use rayon::ThreadPool;
4
5use crate::{
6 error::TxPoolError,
7 service::{TxpoolReadHandle, TxpoolWriteHandle},
8 txpool::TxpoolDatabase,
9};
10
11#[cold]
13#[inline(never)] pub fn init_with_pool(
22 database: fjall::Database,
23 pool: Arc<ThreadPool>,
24) -> Result<(TxpoolReadHandle, TxpoolWriteHandle), TxPoolError> {
25 let database = Arc::new(TxpoolDatabase::open_with_database(database)?);
26
27 let readers = TxpoolReadHandle {
29 txpool: Arc::clone(&database),
30 pool: Arc::clone(&pool),
31 };
32 let writer = TxpoolWriteHandle {
33 txpool: Arc::clone(&database),
34 pool,
35 };
36
37 Ok((readers, writer))
38}