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