Use RwLock instead of Mutex to allow for parallel reads and add get_current_swap endpoint

This commit is contained in:
binarybaron 2023-08-11 15:29:59 +02:00
parent 849e6e7a14
commit ffbbe24010
2 changed files with 24 additions and 10 deletions

View file

@ -156,6 +156,9 @@ pub fn register_modules(context: Arc<Context>) -> RpcModule<Arc<Context>> {
list_sellers(rendezvous_point.clone(), &context).await
})
.expect("Could not register RPC method list_sellers");
module.register_async_method("get_current_swap", |_, context| async move {
get_current_swap(&context).await
}).expect("Could not register RPC method get_current_swap");
module
}
@ -170,6 +173,10 @@ async fn execute_request(
.map_err(|err| jsonrpsee_core::Error::Custom(err.to_string()))
}
async fn get_current_swap(context: &Arc<Context>) -> Result<serde_json::Value, jsonrpsee_core::Error> {
execute_request(Method::GetCurrentSwap, context).await
}
async fn get_bitcoin_balance(
context: &Arc<Context>,
) -> Result<serde_json::Value, jsonrpsee_core::Error> {