Skip to content

Commit 8a7afbc

Browse files
committed
f Add should_persist flag to transaction_unconfirmed
1 parent 6cdbb5e commit 8a7afbc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lightning/src/util/sweep.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,21 @@ where
667667
.and_then(|o| o.status.confirmation_height());
668668

669669
// Unconfirm all >= this height.
670+
let mut should_persist = false;
670671
state_lock
671672
.outputs
672673
.iter_mut()
673674
.filter(|o| o.status.confirmation_height() >= unconf_height)
674-
.for_each(|o| o.status.unconfirmed());
675+
.for_each(|o| {
676+
should_persist = true;
677+
o.status.unconfirmed()
678+
});
675679

676-
self.persist_state(&*state_lock).unwrap_or_else(|e| {
677-
log_error!(self.logger, "Error persisting OutputSweeper: {:?}", e);
678-
});
680+
if should_persist {
681+
self.persist_state(&*state_lock).unwrap_or_else(|e| {
682+
log_error!(self.logger, "Error persisting OutputSweeper: {:?}", e);
683+
});
684+
}
679685
}
680686

681687
fn best_block_updated(&self, header: &Header, height: u32) {

0 commit comments

Comments
 (0)