8.3 KiB
8.3 KiB
zcash-android-wallet-sdk / cash.z.wallet.sdk.data / Synchronizer
Synchronizer
interface Synchronizer
Primary interface for interacting with the SDK. Defines the contract that specific implementations like MockSynchronizer and SdkSynchronizer fulfill. Given the language-level support for coroutines, we favor their use in the SDK and incorporate that choice into this contract.
Properties
Name | Summary |
---|---|
isConnected | abstract val isConnected: Boolean A flag indicating whether this Synchronizer is connected to its lightwalletd server. When false, a UI element may want to turn red. |
isScanning | abstract val isScanning: Boolean A flag indicating whether this Synchronizer is actively decrypting compact blocks, searching for transactions. When true, a UI element may want to turn yellow. |
isSyncing | abstract val isSyncing: Boolean A flag indicating whether this Synchronizer is actively downloading compact blocks. When true, a UI element may want to turn yellow. |
onCriticalErrorHandler | abstract var onCriticalErrorHandler: (( Throwable ?) -> Boolean )? Gets or sets a global error handler. This is a useful hook for handling unexpected critical errors. |
onProcessorErrorHandler | abstract var onProcessorErrorHandler: (( Throwable ?) -> Boolean )? An error handler for exceptions during processing. For instance, a block might be missing or a reorg may get mishandled or the database may get corrupted. |
onSubmissionErrorHandler | abstract var onSubmissionErrorHandler: (( Throwable ?) -> Boolean )? An error handler for exceptions while submitting transactions to lightwalletd. For instance, a transaction may get rejected because it would be a double-spend or the user might lose their cellphone signal. |
Functions
Name | Summary |
---|---|
balances | abstract fun balances(): ReceiveChannel< Wallet.WalletBalance > A stream of balance values, separately reflecting both the available and total balance. |
cancelSend | abstract fun cancelSend(transaction: SentTransaction ): Boolean Attempts to cancel a previously sent transaction. Typically, cancellation is only an option if the transaction has not yet been submitted to the server. |
clearedTransactions | abstract fun clearedTransactions(): ReceiveChannel< List < ClearedTransaction >> A stream of all the transactions that are on the blockchain. Implementations should consider only returning a subset like the most recent 100 transactions, perhaps through paging the underlying database. |
getAddress | abstract suspend fun getAddress(accountId: Int = 0): String Gets the address for the given account. |
lastBalance | abstract fun lastBalance(): Wallet.WalletBalance Holds the most recent value that was transmitted through the balances channel. Typically, if the underlying channel is a BroadcastChannel (and it should be), then this value is simply balanceChannel.value |
lastCleared | abstract fun lastCleared(): List < ClearedTransaction > Holds the most recent value that was transmitted through the clearedTransactions channel. Typically, if the underlying channel is a BroadcastChannel (and it should be), then this value is simply clearedChannel.value |
lastPending | abstract fun lastPending(): List < PendingTransaction > Holds the most recent value that was transmitted through the pendingTransactions channel. Typically, if the underlying channel is a BroadcastChannel (and it should be),then this value is simply pendingChannel.value |
pendingTransactions | abstract fun pendingTransactions(): ReceiveChannel< List < PendingTransaction >> A stream of all the outbound pending transaction that have been sent but are awaiting confirmations. |
progress | abstract fun progress(): ReceiveChannel< Int > A stream of progress values, typically corresponding to this Synchronizer downloading blocks. Typically, any non- zero value below 100 indicates that progress indicators can be shown and a value of 100 signals that progress is complete and any progress indicators can be hidden. |
sendToAddress | abstract suspend fun sendToAddress(zatoshi: Long , toAddress: String , memo: String = "", fromAccountId: Int = 0): PendingTransaction Sends zatoshi. |
start | abstract fun start(parentScope: CoroutineScope): Synchronizer Starts this synchronizer within the given scope. |
stop | abstract fun stop(): Unit Stop this synchronizer. Implementations should ensure that calling this method cancels all jobs that were created by this instance. |
Inheritors
Name | Summary |
---|---|
MockSynchronizer | abstract class MockSynchronizer : Synchronizer , CoroutineScope Utility for building UIs. It does the best it can to mock the SDKSynchronizer so that it can be dropped into any project and drive the UI. It generates active transactions in response to funds being sent and generates random received transactions, periodically. |
SdkSynchronizer | class SdkSynchronizer : Synchronizer A synchronizer that attempts to remain operational, despite any number of errors that can occur. It acts as the glue that ties all the pieces of the SDK together. Each component of the SDK is designed for the potential of stand-alone usage but coordinating all the interactions is non-trivial. So the synchronizer facilitates this, acting as reference that demonstrates how all the pieces can be tied together. Its goal is to allow a developer to focus on their app rather than the nuances of how Zcash works. |