diff --git a/bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairApiSyncer.kt b/bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairApiSyncer.kt index ac159978..1d474300 100644 --- a/bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairApiSyncer.kt +++ b/bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairApiSyncer.kt @@ -47,7 +47,7 @@ class BlockchairApiSyncer( } override fun syncLastBlock() { - syncLastBlockSingle() + Single.create { fetchLastBlock() } .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe({}, { @@ -66,7 +66,7 @@ class BlockchairApiSyncer( listener?.onSyncFailed(error) } - private fun syncLastBlockSingle(): Single = Single.create { + private fun fetchLastBlock() { val blockHeaderItem = lastBlockProvider.lastBlockHeader() val header = BlockHeader( version = 0, @@ -85,6 +85,7 @@ class BlockchairApiSyncer( val allKeys = storage.getPublicKeys() val stopHeight = storage.downloadedTransactionsBestBlockHeight() fetchRecursive(allKeys, allKeys, stopHeight) + fetchLastBlock() apiSyncStateManager.restored = true listener?.onSyncSuccess()