Skip to content

Commit

Permalink
[#1170] Regular transaction flow emitting
Browse files Browse the repository at this point in the history
Although zcash/librustzcash#918 will provide information on when to trigger transaction polling, this partly solve the issue as well
  • Loading branch information
HonzaR committed Sep 4, 2023
1 parent 4a0b63d commit 0a7620b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private fun ComposablePreview() {
MaterialTheme {
// TODO [#1090]: Demo: Add Addresses and Transactions Compose Previews
// TODO [#1090]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1090
// Transactions()
// TransactionsView()
}
}

Expand Down Expand Up @@ -127,7 +127,7 @@ private fun TransactionsMainContent(
val memos = synchronizer.getMemos(it)
queryScope.launch {
memos.toList().run {
Twig.debug {
Twig.info {
"Transaction memos: count: $size, contains: ${joinToString().ifEmpty { "-" }}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ class CompactBlockProcessor internal constructor(
SyncingResult.UpdateBirthday -> {
updateBirthdayHeight()
}
SyncingResult.EnhanceSuccess -> {
Twig.info { "Triggering transaction refresh now" }
// Invalidate transaction data
refreshTransactions(transactionStorage = repository)
}
is SyncingResult.Failure -> {
syncingResult = rangeSyncProgress.resultState
return@collect
Expand Down Expand Up @@ -553,6 +558,12 @@ class CompactBlockProcessor internal constructor(
updateBirthdayHeight()
SyncingResult.AllSuccess
}
SyncingResult.EnhanceSuccess -> {
Twig.info { "Triggering transaction refresh now" }
// Invalidate transaction data and return the common batch syncing success result to the caller
refreshTransactions(transactionStorage = repository)
SyncingResult.AllSuccess
}
is SyncingResult.Failure -> {
rangeSyncProgress.resultState
} else -> {
Expand Down Expand Up @@ -598,6 +609,13 @@ class CompactBlockProcessor internal constructor(
return BlockProcessingResult.Success
}

/**
* This invalidates transaction storage to trigger data refreshing for its subscribers.
*/
private fun refreshTransactions(transactionStorage: DerivedDataRepository) {
transactionStorage.invalidate()
}

@Suppress("ReturnCount")
internal suspend fun runSbSSyncingPreparation(
backend: TypesafeBackend,
Expand Down Expand Up @@ -701,6 +719,11 @@ class CompactBlockProcessor internal constructor(
SyncingResult.UpdateBirthday -> {
updateBirthdayHeight()
}
SyncingResult.EnhanceSuccess -> {
Twig.info { "Triggering transaction refresh now" }
// Invalidate transaction data
refreshTransactions(transactionStorage = repository)
}
is SyncingResult.Failure -> {
syncingResult = rangeSyncProgress.resultState
return@collect
Expand Down Expand Up @@ -1418,8 +1441,8 @@ class CompactBlockProcessor internal constructor(
enhancingResult
}
else -> {
// Transactions enhanced correctly. Now we return common sync success state.
SyncingResult.AllSuccess
// Transactions enhanced correctly. Let's continue with block processing.
enhancingResult
}
}
emit(
Expand Down

0 comments on commit 0a7620b

Please sign in to comment.