1f18042d52
- Correct typo and compiler warning in Rust. 'trait objects without an explicity dyn' are deprecated and this is a warning as of Rust 1.37 - update dependencies - update documentation docs |
||
---|---|---|
.. | ||
-sync-state | ||
-init-.md | ||
README.md | ||
active-transactions.md | ||
all-transactions.md | ||
balance.md | ||
balances.md | ||
cancel-send.md | ||
cleared-transactions.md | ||
coroutine-scope.md | ||
get-address.md | ||
index.md | ||
is-connected.md | ||
is-first-run.md | ||
is-scanning.md | ||
is-stale.md | ||
is-syncing.md | ||
last-balance.md | ||
last-cleared.md | ||
last-pending.md | ||
on-critical-error-handler.md | ||
on-processor-error-handler.md | ||
on-submission-error-handler.md | ||
on-synchronizer-error-listener.md | ||
on-transactions-changed.md | ||
pending-transactions.md | ||
progress.md | ||
refresh-balance.md | ||
send-to-address.md | ||
start.md | ||
stop.md |
README.md
zcash-android-wallet-sdk / cash.z.wallet.sdk.data / SdkSynchronizer
SdkSynchronizer
class SdkSynchronizer :
Synchronizer
The glue. Downloads compact blocks to the database and then scans them for transactions. In order to serve that purpose, this class glues together a variety of key components. Each component contributes to the team effort of providing a simple source of truth to interact with.
Another way of thinking about this class is the reference that demonstrates how all the pieces can be tied together.
Parameters
downloader
- the component that downloads compact blocks and exposes them as a stream
processor
- the component that saves the downloaded compact blocks to the cache and then scans those blocks for
data related to this wallet.
repository
- the component that exposes streams of wallet transaction information.
activeTransactionManager
- the component that manages the lifecycle of active transactions. This includes sent
transactions that have not been mined.
wallet
- the component that wraps the JNI layer that interacts with librustzcash and manages wallet config.
batchSize
- the number of compact blocks to download at a time.
staleTolerance
- the number of blocks to allow before considering our data to be stale
blockPollFrequency
- how often to poll for compact blocks. Once all missing blocks have been downloaded, this
number represents the number of milliseconds the synchronizer will wait before checking for newly mined blocks.
Types
Name | Summary |
---|---|
SyncState | sealed class SyncState Represents the initial state of the Synchronizer. |
Constructors
Name | Summary |
---|---|
<init> | SdkSynchronizer(downloader: CompactBlockStream , processor: CompactBlockProcessor , repository: TransactionRepository , activeTransactionManager: ActiveTransactionManager , wallet: Wallet , batchSize: Int = 1000, staleTolerance: Int = 10, blockPollFrequency: Long = CompactBlockStream.DEFAULT_POLL_INTERVAL) The glue. Downloads compact blocks to the database and then scans them for transactions. In order to serve that purpose, this class glues together a variety of key components. Each component contributes to the team effort of providing a simple source of truth to interact with. |
Properties
Name | Summary |
---|---|
onSynchronizerErrorListener | var onSynchronizerErrorListener: (( Throwable ?) -> Boolean )? Sets a listener to be notified of uncaught Synchronizer errors. When null, errors will only be logged. |
Functions
Name | Summary |
---|---|
activeTransactions | fun activeTransactions(): ReceiveChannel< Map < ActiveTransaction , TransactionState >> A stream of all the wallet transactions, delegated to the activeTransactionManager. |
allTransactions | fun allTransactions(): ReceiveChannel< List < WalletTransaction >> A stream of all the wallet transactions, delegated to the repository. |
balance | fun balance(): ReceiveChannel< Wallet.WalletBalance > A stream of balance values, delegated to the wallet. |
cancelSend | fun cancelSend(transaction: ActiveSendTransaction ): Boolean Attempts to cancel a previously sent transaction. Transactions can only be cancelled during the calculation phase before they've been submitted to the server. This method will return false when it is too late to cancel. This logic is delegated to the activeTransactionManager, which knows the state of the given transaction. |
getAddress | fun getAddress(accountId: Int ): String Gets the address for the given account. |
isFirstRun | suspend fun isFirstRun(): Boolean A flag to indicate that the initial state of this synchronizer was firstRun. This is useful for knowing whether initializing the database is required and whether to show things like"first run walk-throughs." |
isStale | suspend fun isStale(): Boolean A flag to indicate that this Synchronizer is significantly out of sync with it's server. This is determined by the delta between the current block height reported by the server and the latest block we have stored in cache. Whenever this delta is greater than the staleTolerance, this function returns true. This is intended for showing progress indicators when the user returns to the app after having not used it for a long period. Typically, this means the user may have to wait for downloading to occur and the current balance and transaction information cannot be trusted as 100% accurate. |
progress | fun progress(): ReceiveChannel< Int > A stream of progress values, corresponding to this Synchronizer downloading blocks, delegated to the downloader. 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. At that point, the synchronizer switches from catching up on missed blocks to periodically monitoring for newly mined blocks. |
sendToAddress | suspend fun sendToAddress(zatoshi: Long , toAddress: String , memo: String , fromAccountId: Int ): Unit Sends zatoshi. |
start | fun start(parentScope: CoroutineScope): Synchronizer Starts this synchronizer within the given scope. For simplicity, attempting to start an instance that has already been started will throw a SynchronizerException.FalseStart exception. This reduces the complexity of managing resources that must be recycled. Instead, each synchronizer is designed to have a long lifespan and should be started from an activity, application or session. |
stop | fun stop(): Unit Stops this synchronizer by stopping the downloader, repository, and activeTransactionManager, then cancelling the parent job. Note that we do not cancel the parent scope that was passed into start because the synchronizer does not own that scope, it just uses it for launching children. |