Skip to content

Commit

Permalink
Wallet: remove references to deprecated autosaveToFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Sep 2, 2024
1 parent c43ef27 commit cef8b77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/org/bitcoinj/wallet/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
* auto-save feature that simplifies this for you although you're still responsible for manually triggering a save when
* your app is about to quit because the auto-save feature waits a moment before actually committing to disk to avoid IO
* thrashing when the wallet is changing very fast (e.g. due to a block chain sync). See
* {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
* {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* for more information about this.</p>
*/
public class Wallet extends BaseTaggableObject
Expand Down Expand Up @@ -1051,7 +1051,7 @@ public boolean importKey(ECKey key) {

/**
* Imports the given keys to the wallet.
* If {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
* If {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* has been called, triggers an auto save bypassing the normal coalescing delay and event handlers.
* Returns the number of keys added, after duplicates are ignored. The onKeyAdded event will be called for each key
* in the list that was not already present.
Expand Down Expand Up @@ -1834,7 +1834,7 @@ public RiskAnalysis.Analyzer getRiskAnalyzer() {
* In this way disk IO can be rate limited. It's a good idea to set this as otherwise the wallet can change very
* frequently, e.g. if there are a lot of transactions in it or during block sync, and there will be a lot of redundant
* writes. Note that when a new key is added, that always results in an immediate save regardless of
* delayTime. <b>You should still save the wallet manually using {@link Wallet#saveToFile(File)} when your program
* delay. <b>You should still save the wallet manually using {@link Wallet#saveToFile(File)} when your program
* is about to shut down as the JVM will not wait for the background thread.</b></p>
*
* <p>An event listener can be provided. It will be called on a background thread
Expand Down Expand Up @@ -1868,7 +1868,7 @@ public WalletFiles autosaveToFile(File f, long delayTime, TimeUnit timeUnit, @Nu
/**
* <p>
* Disables auto-saving, after it had been enabled with
* {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
* {@link Wallet#autosaveToFile(File, Duration, WalletFiles.Listener)}
* before. This method blocks until finished.
* </p>
*/
Expand Down
5 changes: 2 additions & 3 deletions core/src/test/java/org/bitcoinj/wallet/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -1708,7 +1707,7 @@ public void autosaveImmediate() throws Exception {
File f = File.createTempFile("bitcoinj-unit-test", null);
Sha256Hash hash1 = Sha256Hash.of(f);
// Start with zero delay and ensure the wallet file changes after adding a key.
wallet.autosaveToFile(f, 0, TimeUnit.SECONDS, null);
wallet.autosaveToFile(f, Duration.ZERO, null);
ECKey key = wallet.freshReceiveKey();
Sha256Hash hash2 = Sha256Hash.of(f);
assertFalse("Wallet not saved after generating fresh key", hash1.equals(hash2)); // File has changed.
Expand All @@ -1729,7 +1728,7 @@ public void autosaveDelayed() throws Exception {
final CountDownLatch latch = new CountDownLatch(3);
File f = File.createTempFile("bitcoinj-unit-test", null);
Sha256Hash hash1 = Sha256Hash.of(f);
wallet.autosaveToFile(f, 1, TimeUnit.SECONDS,
wallet.autosaveToFile(f, Duration.ofSeconds(1),
new WalletFiles.Listener() {
@Override
public void onBeforeAutoSave(File tempFile) {
Expand Down

0 comments on commit cef8b77

Please sign in to comment.