Package org.bitcoinj.wallet
Class WalletFiles
- java.lang.Object
-
- org.bitcoinj.wallet.WalletFiles
-
public class WalletFiles extends java.lang.ObjectA class that handles atomic and optionally delayed writing of the wallet file to disk. In future: backups too. It can be useful to delay writing of a wallet file to disk on slow devices where disk and serialization overhead can come to dominate the chain processing speed, i.e. on Android phones. By coalescing writes and doing serialization and disk IO on a background thread performance can be improved.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWalletFiles.ListenerImplementors can do pre/post treatment of the wallet file.
-
Constructor Summary
Constructors Constructor Description WalletFiles(Wallet wallet, java.io.File file, long delayTime, java.util.concurrent.TimeUnit timeUnit)Deprecated.WalletFiles(Wallet wallet, java.io.File file, java.time.Duration delay)Initialize atomic and optionally delayed writing of the wallet file to disk.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WalletgetWallet()Get theWalletthisWalletFilesis managing.voidsaveLater()Queues up a save in the background.voidsaveNow()Actually write the wallet file to disk, using an atomic rename when possible.voidsetListener(WalletFiles.Listener listener)The given listener will be called on the autosave thread before and after the wallet is saved to disk.voidshutdownAndWait()Shut down auto-saving.
-
-
-
Constructor Detail
-
WalletFiles
public WalletFiles(Wallet wallet, java.io.File file, java.time.Duration delay)
Initialize atomic and optionally delayed writing of the wallet file to disk. Note the initial wallet state isn't saved automatically. TheWalletcallssaveNow()orsaveLater()as wallet state changes, depending on the urgency of the changes.
-
WalletFiles
@Deprecated public WalletFiles(Wallet wallet, java.io.File file, long delayTime, java.util.concurrent.TimeUnit timeUnit)
Deprecated.
-
-
Method Detail
-
getWallet
public Wallet getWallet()
Get theWalletthisWalletFilesis managing.
-
setListener
public void setListener(@Nonnull WalletFiles.Listener listener)The given listener will be called on the autosave thread before and after the wallet is saved to disk.
-
saveNow
public void saveNow() throws java.io.IOExceptionActually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread.- Throws:
java.io.IOException
-
saveLater
public void saveLater()
Queues up a save in the background. Useful for not very important wallet changes.
-
shutdownAndWait
public void shutdownAndWait()
Shut down auto-saving.
-
-