Skip to content

Commit

Permalink
Fixes from orbitalturtle review
Browse files Browse the repository at this point in the history
To be squashed into dcee480
  • Loading branch information
sr-gi committed Oct 17, 2022
1 parent 38d4174 commit 13b2f9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion teos/src/carrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ impl Carrier {
}

/// Checks whether a given transaction can be found in the mempool.
///
/// This uses `getrawtransaction` under the hood and, therefore, its behavior depends on whether `txindex` is enabled in bitcoind.
/// If `txindex` is disabled (default), it will only pull data from the mempool. Otherwise, it will also pull data from the transaction
/// index. Hence, we need to check whether the returned struct has any of the block related datum set (such as `blockhash`).
pub(crate) fn in_mempool(&self, txid: &Txid) -> bool {
self.hang_until_bitcoind_reachable();

match self.bitcoin_cli.get_raw_transaction_info(txid, None) {
Ok(_) => true,
Ok(tx) => tx.blockhash.is_none(),
Err(JsonRpcError(RpcError(rpcerr))) => match rpcerr.code {
rpc_errors::RPC_INVALID_ADDRESS_OR_KEY => {
log::info!("Transaction not found in mempool: {}", txid);
Expand Down
5 changes: 4 additions & 1 deletion teos/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ impl chain::Listen for Responder {
fn block_disconnected(&self, header: &BlockHeader, height: u32) {
log::warn!("Block disconnected: {}", header.block_hash());
self.carrier.lock().unwrap().update_height(height);
self.tx_index.lock().unwrap().fix(header);
self.tx_index
.lock()
.unwrap()
.remove_disconnected_block(header);

for tracker in self.trackers.lock().unwrap().values_mut() {
// The transaction has been unconfirmed. Flag it as reorged out so we can rebroadcast it.
Expand Down

0 comments on commit 13b2f9e

Please sign in to comment.