zcash-android-wallet-sdk/docs/-mock-synchronizer
Kevin Gorham afa142e1c9 Update docs 2019-03-30 12:22:20 -04:00
..
-init-.md Update docs 2019-03-30 12:22:20 -04:00
README.md Update docs 2019-03-30 12:22:20 -04:00
active-transactions.md Add docs folder with Synchronizer documentation 2019-03-29 02:31:25 -04:00
all-transactions.md Add docs folder with Synchronizer documentation 2019-03-29 02:31:25 -04:00
balance.md Add docs folder with Synchronizer documentation 2019-03-29 02:31:25 -04:00
cancel-send.md Update docs 2019-03-30 12:22:20 -04:00
coroutine-context.md Update docs 2019-03-30 12:22:20 -04:00
get-address.md Update docs 2019-03-30 12:22:20 -04:00
is-first-run.md Update docs 2019-03-30 12:22:20 -04:00
is-stale.md Update docs 2019-03-30 12:22:20 -04:00
on-synchronizer-error-listener.md Update docs 2019-03-30 12:22:20 -04:00
progress.md Add docs folder with Synchronizer documentation 2019-03-29 02:31:25 -04:00
send-to-address.md Update docs 2019-03-30 12:22:20 -04:00
start.md Update docs 2019-03-30 12:22:20 -04:00
stop.md Update docs 2019-03-30 12:22:20 -04:00

README.md

zcash-android-wallet-sdk / cash.z.wallet.sdk.data / MockSynchronizer

MockSynchronizer

open 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.

Parameters

transactionInterval - the time in milliseconds between receive transactions being added because those are the only ones auto-generated. Send transactions are triggered by the UI. Transactions are polled at half this interval.

initialLoadDuration - the time in milliseconds it should take to simulate the initial load. The progress channel will send regular updates such that it reaches 100 in this amount of time.

activeTransactionUpdateFrequency - the amount of time in milliseconds between updates to an active transaction's state. Active transactions move through their lifecycle and increment their state at this rate.

isFirstRun - whether this Mock should return true for isFirstRun. Defaults to a random boolean.

isStale - whether this Mock should return true for isStale. When null, this will follow the default behavior of returning true about 10% of the time.

onSynchronizerErrorListener - presently ignored because there are not yet any errors in mock.

Constructors

Name Summary
<init> MockSynchronizer(transactionInterval: Long= 30_000L, initialLoadDuration:Long= 5_000L, activeTransactionUpdateFrequency:Long= 3_000L, isFirstRun:Boolean= Random.nextBoolean(), isStale:Boolean? = null, onSynchronizerErrorListener: ((Throwable?) -> Boolean)? = null)
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.

Properties

Name Summary
coroutineContext open val coroutineContext: CoroutineContext
Coroutine context used for the CoroutineScope implementation, used to mock asynchronous behaviors.
onSynchronizerErrorListener open var onSynchronizerErrorListener: ((Throwable?) -> Boolean)?
presently ignored because there are not yet any errors in mock.

Functions

Name Summary
activeTransactions open fun activeTransactions(): ReceiveChannel<Map<ActiveTransaction, TransactionState>>
A stream of all the active transactions.
allTransactions open fun allTransactions(): ReceiveChannel<List<WalletTransaction>>
A stream of all the wallet transactions.
balance open fun balance(): ReceiveChannel<Wallet.WalletBalance>
A stream of balance values.
cancelSend open fun cancelSend(transaction: ActiveSendTransaction): Boolean
Sets the state of the given transaction to 'Cancelled'.
getAddress open fun getAddress(accountId: Int): String
Returns the mockAddress. This address is not usable.
isFirstRun open suspend fun isFirstRun(): Boolean
Returns isFirstRun as provided during initialization of this MockSynchronizer.
isStale open suspend fun isStale(): Boolean
Returns true roughly 10% of the time and then resets to false after some delay.
progress open 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 open suspend fun sendToAddress(zatoshi: Long, toAddress: String, memo: String, fromAccountId: Int): Unit
Uses the forge to fabricate a transaction and then walk it through the transaction lifecycle in a useful way. This method will validate the zatoshi amount and toAddress a bit to help with UI validation.
start open fun start(parentScope: CoroutineScope): Synchronizer
Starts this mock Synchronizer.
stop open fun stop(): Unit
Stops this mock Synchronizer by cancelling its primary job.