Skip to content

Commit c163863

Browse files
committed
fix(runtime,core-db): wait for chain sync and include empty-asset chains; add ChainRegistry diagnostics
1 parent 56ec45f commit c163863

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

core-db/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
sourceSets {
3333
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
3434
}
35-
namespace 'jp.co.soramitsu.core_db'
35+
namespace = 'jp.co.soramitsu.core_db'
3636
}
3737

3838
ksp {

core-db/src/main/java/jp/co/soramitsu/coredb/dao/ChainDao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ abstract class ChainDao {
164164

165165
@Query("SELECT * FROM chains WHERE id = :chainId")
166166
@Transaction
167-
abstract suspend fun getJoinChainInfo(chainId: String): JoinedChainInfo
167+
abstract suspend fun getJoinChainInfo(chainId: String): JoinedChainInfo?
168168

169169
@Query("SELECT * FROM chains")
170170
@Transaction

runtime/src/main/java/jp/co/soramitsu/runtime/multiNetwork/chain/ChainSyncService.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.co.soramitsu.runtime.multiNetwork.chain
22

3+
import android.util.Log
34
import jp.co.soramitsu.common.resources.ContextManager
45
import jp.co.soramitsu.coredb.dao.AssetDao
56
import jp.co.soramitsu.coredb.dao.ChainDao
@@ -32,19 +33,21 @@ class ChainSyncService(
3233
}
3334

3435
private suspend fun configChainsSyncUp(): List<Chain> = supervisorScope {
36+
val tag = "ChainRegistry"
3537
val localChainsJoinedInfo = dao.getJoinChainInfo()
3638
val localChainsJoinedInfoMap = localChainsJoinedInfo.associateBy { it.chain.id }
3739

3840
val remoteChains = chainFetcher.getChains()
39-
.filter {
40-
!it.disabled && (it.assets?.isNotEmpty() == true)
41-
}
41+
.filter { !it.disabled }
4242
.map {
4343
it.toChain()
4444
}
4545

4646
val remoteMapping = remoteChains.associateBy(Chain::id)
4747

48+
Log.d(tag, "remote chains fetched: ${remoteChains.size}")
49+
remoteChains.take(5).forEach { Log.d(tag, "remote chain id: ${it.id}") }
50+
4851
val mappedRemoteChains = remoteChains.map { mapChainToChainLocal(it) }
4952
val chainsSyncDeferred = async {
5053
val chainsToUpdate: MutableList<ChainLocal> = mutableListOf()
@@ -162,6 +165,10 @@ class ChainSyncService(
162165

163166
dao.deleteChains(chainsToDelete)
164167

168+
val postLocal = dao.getJoinChainInfo()
169+
Log.d(tag, "local chains after sync: ${postLocal.size}")
170+
postLocal.take(5).forEach { Log.d(tag, "local chain id: ${it.chain.id}") }
171+
165172
remoteChains
166173
}
167174
}

runtime/src/main/java/jp/co/soramitsu/runtime/multiNetwork/chain/ChainsRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ChainsRepository(private val chainDao: ChainDao) {
4646

4747
suspend fun getChain(chainId: ChainId): Chain = withContext(Dispatchers.IO) {
4848
// Be resilient on fresh installs/after data clears: wait briefly for chain sync
49-
repeat(50) { // ~15s at 300ms per attempt
49+
repeat(200) { // ~60s at 300ms per attempt
5050
val local = chainDao.getJoinChainInfo()
5151
val found = local.firstOrNull { it.chain.id == chainId }
5252
if (found != null) return@withContext mapChainLocalToChain(found)

0 commit comments

Comments
 (0)