Improvement: Simplify Initializer to get rid of unnecessary inheritance.

This commit is contained in:
Kevin Gorham 2021-05-07 03:54:18 -04:00
parent 670ec68cd5
commit 8fb56ff80c
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
2 changed files with 9 additions and 19 deletions

View File

@ -16,13 +16,13 @@ import java.io.File
/** /**
* Simplified Initializer focused on starting from a ViewingKey. * Simplified Initializer focused on starting from a ViewingKey.
*/ */
class Initializer constructor(appContext: Context, onCriticalErrorHandler: ((Throwable?) -> Boolean)? = null, config: Config) : SdkSynchronizer.SdkInitializer { class Initializer constructor(appContext: Context, onCriticalErrorHandler: ((Throwable?) -> Boolean)? = null, config: Config) {
override val context = appContext.applicationContext val context = appContext.applicationContext
override val rustBackend: RustBackend val rustBackend: RustBackend
override val network: ZcashNetwork val network: ZcashNetwork
override val alias: String val alias: String
override val host: String val host: String
override val port: Int val port: Int
val viewingKeys: List<UnifiedViewingKey> val viewingKeys: List<UnifiedViewingKey>
val birthday: WalletBirthday val birthday: WalletBirthday
@ -32,7 +32,7 @@ class Initializer constructor(appContext: Context, onCriticalErrorHandler: ((Thr
* function has a return value is so that all error handlers work with the same signature which * function has a return value is so that all error handlers work with the same signature which
* allows one function to handle all errors in simple apps. * allows one function to handle all errors in simple apps.
*/ */
override var onCriticalErrorHandler: ((Throwable?) -> Boolean)? = onCriticalErrorHandler var onCriticalErrorHandler: ((Throwable?) -> Boolean)? = onCriticalErrorHandler
/** /**
* True when accounts have been created by this initializer. * True when accounts have been created by this initializer.

View File

@ -691,16 +691,6 @@ class SdkSynchronizer internal constructor(
) )
} }
interface SdkInitializer {
val context: Context
val rustBackend: RustBackend
val network: ZcashNetwork
val host: String
val port: Int
val alias: String
val onCriticalErrorHandler: ((Throwable?) -> Boolean)?
}
interface Erasable { interface Erasable {
/** /**
* Erase content related to this SDK. * Erase content related to this SDK.
@ -760,7 +750,7 @@ class SdkSynchronizer internal constructor(
*/ */
@Suppress("FunctionName") @Suppress("FunctionName")
fun Synchronizer( fun Synchronizer(
initializer: SdkSynchronizer.SdkInitializer, initializer: Initializer,
repository: TransactionRepository = repository: TransactionRepository =
PagedTransactionRepository(initializer.context, 1000, initializer.rustBackend.pathDataDb), // TODO: fix this pagesize bug, small pages should not crash the app. It crashes with: Uncaught Exception: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. and is probably related to FlowPagedList PagedTransactionRepository(initializer.context, 1000, initializer.rustBackend.pathDataDb), // TODO: fix this pagesize bug, small pages should not crash the app. It crashes with: Uncaught Exception: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. and is probably related to FlowPagedList
blockStore: CompactBlockStore = CompactBlockDbStore(initializer.context, initializer.rustBackend.pathCacheDb), blockStore: CompactBlockStore = CompactBlockDbStore(initializer.context, initializer.rustBackend.pathCacheDb),