prevent unwrap(), poisoned data
This commit is contained in:
@@ -1470,26 +1470,43 @@ pub fn scan_full_tx(&self, tx: &Transaction, height: i32, datetime: u64) {
|
||||
// Do it in a short scope because of the write lock.
|
||||
{
|
||||
info!("A sapling output was sent in {}", tx.txid());
|
||||
let mut txs = self.txs.write().unwrap();
|
||||
if txs.get(&tx.txid()).unwrap().outgoing_metadata.iter()
|
||||
.find(|om| om.address == address && om.value == note.value && om.memo == memo)
|
||||
.is_some() {
|
||||
warn!("Duplicate outgoing metadata");
|
||||
continue;
|
||||
}
|
||||
match self.txs.write() {
|
||||
Ok(mut txs) => {
|
||||
match txs.get(&tx.txid()) {
|
||||
Some(wtx) => {
|
||||
if wtx.outgoing_metadata.iter()
|
||||
.any(|om| om.address == address && om.value == note.value && om.memo == memo)
|
||||
{
|
||||
warn!("Duplicate outgoing metadata");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write the outgoing metadata
|
||||
txs.get_mut(&tx.txid()).unwrap()
|
||||
.outgoing_metadata
|
||||
.push(OutgoingTxMetadata{
|
||||
address, value: note.value, memo,
|
||||
});
|
||||
// Write the outgoing metadata
|
||||
txs.get_mut(&tx.txid()).unwrap()
|
||||
.outgoing_metadata
|
||||
.push(OutgoingTxMetadata {
|
||||
address,
|
||||
value: note.value,
|
||||
memo,
|
||||
});
|
||||
},
|
||||
None => {
|
||||
error!("Can not find any entry for txid : {}", tx.txid());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(poisoned) => {
|
||||
error!("Lock is poisoned: {}", poisoned);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
// Mark this Tx as scanned
|
||||
{
|
||||
let mut txs = self.txs.write().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user