Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Feb 21, 2025
1 parent 49f3d42 commit 8a7c288
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 46 deletions.
2 changes: 0 additions & 2 deletions counterparty-core/counterpartycore/lib/backend/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ def list_unspent(source, allow_unconfirmed_inputs):
def get_vin_info(vin, no_retry=False):
vin_info = vin.get("info")
if vin_info is None:
logger.error("vin info not found")
try:
vin_ctx = get_decoded_transaction(vin["hash"], no_retry=no_retry)
is_segwit = vin_ctx["segwit"]
Expand All @@ -551,7 +550,6 @@ def get_vin_info(vin, no_retry=False):
except exceptions.BitcoindRPCError as e:
raise exceptions.DecodeError("vin not found") from e

Check warning on line 551 in counterparty-core/counterpartycore/lib/backend/bitcoind.py

View check run for this annotation

Codecov / codecov/patch

counterparty-core/counterpartycore/lib/backend/bitcoind.py#L543-L551

Added lines #L543 - L551 were not covered by tests
else:
logger.warning("Using cached vin info")
return vin_info["value"], vin_info["script_pub_key"], vin_info["is_segwit"]

Check warning on line 553 in counterparty-core/counterpartycore/lib/backend/bitcoind.py

View check run for this annotation

Codecov / codecov/patch

counterparty-core/counterpartycore/lib/backend/bitcoind.py#L553

Added line #L553 was not covered by tests


Expand Down
8 changes: 0 additions & 8 deletions counterparty-rs/src/indexer/batch_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ impl From<serde_json::Error> for BatchRpcError {

impl BatchRpcClient {
pub fn new(url: String, user: String, password: String) -> Result<Self, BatchRpcError> {
static INIT: std::sync::Once = std::sync::Once::new();
INIT.call_once(|| {
// Configure uniquement pour reqwest et ses composants
std::env::set_var("REQWEST_LOG", "off");
std::env::set_var("HYPER_LOG", "off");
std::env::set_var("RSFETCHER_LOG", "off");
});

let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));

Expand Down
35 changes: 0 additions & 35 deletions counterparty-rs/src/indexer/bitcoin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ use crate::indexer::block::VinOutput;
use std::sync::{Arc, Mutex, Weak};
use lazy_static::lazy_static;

lazy_static! {
static ref GLOBAL_CLIENT: Mutex<Option<Weak<BitcoinClient>>> = Mutex::new(None);
}

use crate::indexer::batch_rpc::{BatchRpcClient, BATCH_CLIENT};

Expand Down Expand Up @@ -626,7 +623,6 @@ pub trait BitcoinRpc<B>: Send + Clone + 'static {
fn get_block_hash(&self, height: u32) -> Result<BlockHash, Error>;
fn get_block(&self, hash: &BlockHash) -> Result<Box<B>, Error>;
fn get_blockchain_height(&self) -> Result<u32, Error>;
fn get_raw_transaction(&self, txid: &Txid) -> Result<bitcoin::Transaction, Error>;
}

struct GetBlockHash {
Expand Down Expand Up @@ -655,7 +651,6 @@ struct Channels {
get_block_hash: Channel<GetBlockHash>,
get_block: Channel<GetBlock>,
get_blockchain_height: Channel<GetBlockchainHeight>,
get_raw_transaction: Channel<GetRawTransaction>,
}

impl Channels {
Expand All @@ -664,7 +659,6 @@ impl Channels {
get_block_hash: bounded(n),
get_block: bounded(n),
get_blockchain_height: bounded(n),
get_raw_transaction: bounded(n),
}
}
}
Expand All @@ -687,10 +681,6 @@ impl BitcoinClient {
stopper,
channels: Channels::new(n),
};

let client_arc = Arc::new(client.clone());
*GLOBAL_CLIENT.lock().unwrap() = Some(Arc::downgrade(&client_arc));

Ok(client)
}

Expand Down Expand Up @@ -731,11 +721,6 @@ impl BitcoinClient {
if let Ok(GetBlockchainHeight {sender}) = msg {
sender.send(client.get_blockchain_height())?;
}
},
recv(channels.get_raw_transaction.1) -> msg => {
if let Ok(GetRawTransaction {txid, sender}) = msg {
sender.send(client.get_raw_transaction(&txid))?;
}
}
}
}
Expand Down Expand Up @@ -791,22 +776,6 @@ impl BitcoinRpc<Block> for BitcoinClient {
}
}
}

fn get_raw_transaction(&self, txid: &Txid) -> Result<bitcoin::Transaction, Error> {
let (tx, rx) = bounded(1);
self.channels.get_raw_transaction.0.send(GetRawTransaction {
txid: *txid,
sender: tx,
})?;
let (id, done) = self.stopper.subscribe()?;
select! {
recv(done) -> _ => Err(Error::Stopped),
recv(rx) -> result => {
self.stopper.unsubscribe(id)?;
result?
}
}
}
}

#[derive(Clone)]
Expand Down Expand Up @@ -839,10 +808,6 @@ impl BitcoinRpc<Block> for BitcoinClientInner {
fn get_blockchain_height(&self) -> Result<u32, Error> {
Ok(self.client.get_blockchain_info()?.blocks as u32)
}

fn get_raw_transaction(&self, txid: &Txid) -> Result<bitcoin::Transaction, Error> {
Ok(self.client.get_raw_transaction(txid, None)?)
}
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion counterparty-rs/src/indexer/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<L> ConnectionPoolFilter<L> {
message.contains("reuse idle connection") ||
message.contains("put; add idle connection") ||
message.contains("pooling idle connection") ||
hmessage.contains("hyper_util")
message.contains("hyper_util")
}
}

Expand Down

0 comments on commit 8a7c288

Please sign in to comment.