s/observed_txs/finished_txs/g

This commit is contained in:
LLFourn 2021-11-05 12:14:42 +11:00
parent 188d9a4a8b
commit dfb63d389b
No known key found for this signature in database
GPG Key ID: A27093B54DA11F65

View File

@ -101,9 +101,9 @@ impl<'a, D: BatchDatabase> ScriptReq<'a, D> {
} }
(Some(_), None) => { (Some(_), None) => {
details.confirmation_time = None; details.confirmation_time = None;
self.state.observed_txs.push(details); self.state.finished_txs.push(details);
} }
_ => self.state.observed_txs.push(details), _ => self.state.finished_txs.push(details),
} }
} }
None => { None => {
@ -266,7 +266,7 @@ impl<'a, D: BatchDatabase> ConftimeReq<'a, D> {
if let Some(mut tx_details) = tx_details { if let Some(mut tx_details) = tx_details {
tx_details.confirmation_time = confirmation_time; tx_details.confirmation_time = confirmation_time;
self.state.observed_txs.push(tx_details); self.state.finished_txs.push(tx_details);
} }
} }
@ -285,10 +285,15 @@ impl<'a, D: BatchDatabase> ConftimeReq<'a, D> {
struct State<'a, D> { struct State<'a, D> {
db: &'a D, db: &'a D,
last_active_index: HashMap<KeychainKind, usize>, last_active_index: HashMap<KeychainKind, usize>,
/// Transactions where we need to get the full details
tx_needed: VecDeque<Txid>, tx_needed: VecDeque<Txid>,
/// Transactions where we need to get the confirmation time
conftime_needed: VecDeque<Txid>, conftime_needed: VecDeque<Txid>,
observed_txs: Vec<TransactionDetails>, /// Transacitions that we know everything about
finished_txs: Vec<TransactionDetails>,
/// Transactions that discovered conftimes should be inserted into
tx_missing_conftime: HashMap<Txid, TransactionDetails>, tx_missing_conftime: HashMap<Txid, TransactionDetails>,
/// The start of the sync
start_time: Instant, start_time: Instant,
} }
@ -298,7 +303,7 @@ impl<'a, D: BatchDatabase> State<'a, D> {
db, db,
last_active_index: HashMap::default(), last_active_index: HashMap::default(),
conftime_needed: VecDeque::default(), conftime_needed: VecDeque::default(),
observed_txs: vec![], finished_txs: vec![],
tx_needed: VecDeque::default(), tx_needed: VecDeque::default(),
tx_missing_conftime: HashMap::default(), tx_missing_conftime: HashMap::default(),
start_time: Instant::new(), start_time: Instant::new(),
@ -312,8 +317,8 @@ impl<'a, D: BatchDatabase> State<'a, D> {
); );
let existing_txs = self.db.iter_txs(false)?; let existing_txs = self.db.iter_txs(false)?;
let existing_txids: HashSet<Txid> = existing_txs.iter().map(|tx| tx.txid).collect(); let existing_txids: HashSet<Txid> = existing_txs.iter().map(|tx| tx.txid).collect();
let observed_txs = make_txs_consistent(&self.observed_txs); let finished_txs = make_txs_consistent(&self.finished_txs);
let observed_txids: HashSet<Txid> = observed_txs.iter().map(|tx| tx.txid).collect(); let observed_txids: HashSet<Txid> = finished_txs.iter().map(|tx| tx.txid).collect();
let txids_to_delete = existing_txids.difference(&observed_txids); let txids_to_delete = existing_txids.difference(&observed_txids);
let mut batch = self.db.begin_batch(); let mut batch = self.db.begin_batch();
@ -334,8 +339,8 @@ impl<'a, D: BatchDatabase> State<'a, D> {
} }
// Set every tx we observed // Set every tx we observed
for observed_tx in &observed_txs { for finished_tx in &finished_txs {
let tx = observed_tx let tx = finished_tx
.transaction .transaction
.as_ref() .as_ref()
.expect("transaction will always be present here"); .expect("transaction will always be present here");
@ -346,7 +351,7 @@ impl<'a, D: BatchDatabase> State<'a, D> {
// add utxos we own from the new transactions we've seen. // add utxos we own from the new transactions we've seen.
batch.set_utxo(&LocalUtxo { batch.set_utxo(&LocalUtxo {
outpoint: OutPoint { outpoint: OutPoint {
txid: observed_tx.txid, txid: finished_tx.txid,
vout: i as u32, vout: i as u32,
}, },
txout: output.clone(), txout: output.clone(),
@ -354,13 +359,13 @@ impl<'a, D: BatchDatabase> State<'a, D> {
})?; })?;
} }
} }
batch.set_tx(observed_tx)?; batch.set_tx(finished_tx)?;
} }
// we don't do this in the loop above since we may want to delete some of the utxos we // we don't do this in the loop above since we may want to delete some of the utxos we
// just added in case there are new tranasactions that spend form each other. // just added in case there are new tranasactions that spend form each other.
for observed_tx in &observed_txs { for finished_tx in &finished_txs {
let tx = observed_tx let tx = finished_tx
.transaction .transaction
.as_ref() .as_ref()
.expect("transaction will always be present here"); .expect("transaction will always be present here");