Skip to content

Commit

Permalink
chore: format file
Browse files Browse the repository at this point in the history
  • Loading branch information
NonsoAmadi10 committed Apr 14, 2024
1 parent 55168f8 commit c385880
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions roles/jd-server/src/lib/mempool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use roles_logic_sv2::utils::Mutex;
use rpc_sv2::mini_rpc_client;
use rpc_sv2::mini_rpc_client::RpcError;
use std::{convert::TryInto, str::FromStr, sync::Arc};
use stratum_common::bitcoin::{self, hash_types::Txid, util::key};
use stratum_common::bitcoin::{self, hash_types::Txid};

#[derive(Clone, Debug)]
pub struct TransactionWithHash {
Expand Down Expand Up @@ -104,29 +104,26 @@ impl JDsMempool {
.map_err(|e| JdsMempoolError::PoisonLock(e.to_string()))?
.ok_or(JdsMempoolError::NoClient)?;

let mempool: Vec<String> = client
.get_raw_mempool()
.await
.map_err(|err| {
let err_msg = format!("Error occurred during deserialization: {:?}", err);
JdsMempoolError::Rpc(RpcError::Deserialization(err_msg))
})?;
let mempool: Vec<String> = client.get_raw_mempool().await.map_err(|err| {
let err_msg = format!("Error occurred during deserialization: {:?}", err);
JdsMempoolError::Rpc(RpcError::Deserialization(err_msg))
})?;
for id in &mempool {
let key_id = match Txid::from_str(id){
let key_id = match Txid::from_str(id) {
Ok(id) => id,
Err(err) => {
let err_msg = format!("Error occurred during deserialization: {:?}", err);
return Err(JdsMempoolError::Rpc(RpcError::Deserialization(err_msg)))
}
return Err(JdsMempoolError::Rpc(RpcError::Deserialization(err_msg)));
}
};

let tx = self_
.safe_lock(|x| match x.mempool.get(&key_id) {
Some(entry) => entry.clone(),
None => None,
})
.map_err(|e| JdsMempoolError::PoisonLock(e.to_string()))?;

let tx = self_.safe_lock(|x| match x.mempool.get(&key_id) {
Some(entry) => entry.clone(),
None => None,
})
.map_err(|e| JdsMempoolError::PoisonLock(e.to_string()))?;

mempool_ordered.insert(key_id, tx);
}

Expand Down

0 comments on commit c385880

Please sign in to comment.