Skip to content

Commit

Permalink
Fixes from mariocynicys review (2/2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-gi committed Nov 4, 2022
1 parent 18a14ec commit 12852a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions teos/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::carrier::Carrier;
use crate::dbm::DBM;
use crate::extended_appointment::UUID;
use crate::gatekeeper::{Gatekeeper, UserInfo};
use crate::tx_index::{Indexable, TxIndex};
use crate::tx_index::TxIndex;
use crate::watcher::Breach;

/// Number of missed confirmations to wait before rebroadcasting a transaction.
Expand Down Expand Up @@ -595,7 +595,7 @@ impl chain::Listen for Responder {
self.tx_index
.lock()
.unwrap()
.remove_disconnected_block(header);
.remove_disconnected_block(&header.block_hash());

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 Expand Up @@ -883,7 +883,7 @@ mod tests {
let breach = get_random_breach();
let penalty_txid = breach.penalty_tx.txid();

// Add the tx to out txindex
// Add the tx to our txindex
let target_block_hash = *responder.tx_index.lock().unwrap().blocks().get(2).unwrap();
responder
.tx_index
Expand Down
14 changes: 6 additions & 8 deletions teos/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,19 +396,17 @@ pub(crate) async fn create_responder(
dbm: Arc<Mutex<DBM>>,
server_url: &str,
) -> Responder {
let height = if chain.tip().height < IRREVOCABLY_RESOLVED as u32 {
chain.tip().height * 2
} else {
IRREVOCABLY_RESOLVED as u32
};
let height = chain.tip().height;
// For the local TxIndex logic to be sound, our index needs to have, at least, IRREVOCABLY_RESOLVED blocks
debug_assert!(height >= IRREVOCABLY_RESOLVED);

let last_n_blocks = get_last_n_blocks(chain, height as usize).await;
let last_n_blocks = get_last_n_blocks(chain, IRREVOCABLY_RESOLVED as usize).await;

let bitcoin_cli = Arc::new(BitcoindClient::new(server_url, Auth::None).unwrap());
let bitcoind_reachable = Arc::new((Mutex::new(true), Condvar::new()));
let carrier = Carrier::new(bitcoin_cli, bitcoind_reachable, chain.tip().height);
let carrier = Carrier::new(bitcoin_cli, bitcoind_reachable, height);

Responder::new(&last_n_blocks, chain.tip().height, carrier, gatekeeper, dbm)
Responder::new(&last_n_blocks, height, carrier, gatekeeper, dbm)
}

pub(crate) async fn create_watcher(
Expand Down

0 comments on commit 12852a4

Please sign in to comment.