Skip to content

Commit

Permalink
wallet: fix double-save
Browse files Browse the repository at this point in the history
Closes #78
  • Loading branch information
dr-orlovsky committed Jan 1, 2025
1 parent 429c853 commit 2e58208
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<K, D: Descriptor<K>, L2: Layer2Descriptor> Persisting for WalletDescr<K, D,

impl<K, D: Descriptor<K>, L2: Layer2Descriptor> Drop for WalletDescr<K, D, L2> {
fn drop(&mut self) {
if self.is_autosave() {
if self.is_autosave() && self.is_dirty() {

Check warning on line 174 in src/wallet.rs

View check run for this annotation

Codecov / codecov/patch

src/wallet.rs#L174

Added line #L174 was not covered by tests
if let Err(e) = self.store() {
#[cfg(feature = "log")]
log::error!("impossible to automatically-save wallet descriptor on Drop: {e}");
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<L2: Layer2Data> WalletData<L2> {

impl<L2: Layer2Data> Drop for WalletData<L2> {
fn drop(&mut self) {
if self.is_autosave() {
if self.is_autosave() && self.is_dirty() {

Check warning on line 271 in src/wallet.rs

View check run for this annotation

Codecov / codecov/patch

src/wallet.rs#L271

Added line #L271 was not covered by tests
if let Err(e) = self.store() {
#[cfg(feature = "log")]
log::error!("impossible to automatically-save wallet data on Drop: {e}");
Expand Down Expand Up @@ -433,7 +433,7 @@ impl<L2: Layer2Cache> Persisting for WalletCache<L2> {

impl<L2: Layer2Cache> Drop for WalletCache<L2> {
fn drop(&mut self) {
if self.is_autosave() {
if self.is_autosave() && self.is_dirty() {

Check warning on line 436 in src/wallet.rs

View check run for this annotation

Codecov / codecov/patch

src/wallet.rs#L436

Added line #L436 was not covered by tests
if let Err(e) = self.store() {
#[cfg(feature = "log")]
log::error!("impossible to automatically-save wallet cache on Drop: {e}");
Expand Down

0 comments on commit 2e58208

Please sign in to comment.