Skip to content

Commit

Permalink
indexers: make AnyResolver thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 25, 2024
1 parent a3b2e43 commit ba318f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/indexers/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// limitations under the License.

use std::collections::HashMap;
use std::sync::Arc;

use bp::Tx;
use bpstd::Network;
Expand All @@ -44,15 +45,15 @@ pub trait RgbResolver: Send {
#[derive(From)]
#[non_exhaustive]
pub struct AnyResolver {
inner: Box<dyn RgbResolver>,
inner: Arc<dyn RgbResolver + Sync>,
terminal_txes: HashMap<Txid, Tx>,
}

impl AnyResolver {
#[cfg(feature = "electrum_blocking")]
pub fn electrum_blocking(url: &str, config: Option<electrum::Config>) -> Result<Self, String> {
Ok(AnyResolver {
inner: Box::new(
inner: Arc::new(

Check warning on line 56 in src/indexers/any.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/any.rs#L56

Added line #L56 was not covered by tests
electrum::Client::from_config(url, config.unwrap_or_default())
.map_err(|e| e.to_string())?,
),
Expand All @@ -63,7 +64,7 @@ impl AnyResolver {
#[cfg(feature = "esplora_blocking")]
pub fn esplora_blocking(url: &str, config: Option<esplora::Config>) -> Result<Self, String> {
Ok(AnyResolver {
inner: Box::new(
inner: Arc::new(

Check warning on line 67 in src/indexers/any.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/any.rs#L67

Added line #L67 was not covered by tests
esplora::BlockingClient::from_config(url, config.unwrap_or_default())
.map_err(|e| e.to_string())?,
),
Expand All @@ -74,7 +75,7 @@ impl AnyResolver {
#[cfg(feature = "mempool_blocking")]
pub fn mempool_blocking(url: &str, config: Option<esplora::Config>) -> Result<Self, String> {
Ok(AnyResolver {
inner: Box::new(super::mempool_blocking::MemPoolClient::new(
inner: Arc::new(super::mempool_blocking::MemPoolClient::new(

Check warning on line 78 in src/indexers/any.rs

View check run for this annotation

Codecov / codecov/patch

src/indexers/any.rs#L78

Added line #L78 was not covered by tests
url,
config.unwrap_or_default(),
)?),
Expand Down

0 comments on commit ba318f6

Please sign in to comment.