Skip to content

Commit

Permalink
Fetch last block on every sync in BlockchairApiSyncer
Browse files Browse the repository at this point in the history
  • Loading branch information
omurovch committed Jan 22, 2024
1 parent 4956962 commit e5c5c4b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BlockchairApiSyncer(
}

override fun syncLastBlock() {
syncLastBlockSingle()
Single.create<Unit> { fetchLastBlock() }
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe({}, {
Expand All @@ -66,7 +66,7 @@ class BlockchairApiSyncer(
listener?.onSyncFailed(error)
}

private fun syncLastBlockSingle(): Single<Unit> = Single.create {
private fun fetchLastBlock() {
val blockHeaderItem = lastBlockProvider.lastBlockHeader()
val header = BlockHeader(
version = 0,
Expand All @@ -85,6 +85,7 @@ class BlockchairApiSyncer(
val allKeys = storage.getPublicKeys()
val stopHeight = storage.downloadedTransactionsBestBlockHeight()
fetchRecursive(allKeys, allKeys, stopHeight)
fetchLastBlock()

apiSyncStateManager.restored = true
listener?.onSyncSuccess()
Expand Down

0 comments on commit e5c5c4b

Please sign in to comment.