Improvement: Simplify Initializer to get rid of unnecessary inheritance.
This commit is contained in:
parent
670ec68cd5
commit
8fb56ff80c
|
@ -16,13 +16,13 @@ import java.io.File
|
|||
/**
|
||||
* Simplified Initializer focused on starting from a ViewingKey.
|
||||
*/
|
||||
class Initializer constructor(appContext: Context, onCriticalErrorHandler: ((Throwable?) -> Boolean)? = null, config: Config) : SdkSynchronizer.SdkInitializer {
|
||||
override val context = appContext.applicationContext
|
||||
override val rustBackend: RustBackend
|
||||
override val network: ZcashNetwork
|
||||
override val alias: String
|
||||
override val host: String
|
||||
override val port: Int
|
||||
class Initializer constructor(appContext: Context, onCriticalErrorHandler: ((Throwable?) -> Boolean)? = null, config: Config) {
|
||||
val context = appContext.applicationContext
|
||||
val rustBackend: RustBackend
|
||||
val network: ZcashNetwork
|
||||
val alias: String
|
||||
val host: String
|
||||
val port: Int
|
||||
val viewingKeys: List<UnifiedViewingKey>
|
||||
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
|
||||
* 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.
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
* Erase content related to this SDK.
|
||||
|
@ -760,7 +750,7 @@ class SdkSynchronizer internal constructor(
|
|||
*/
|
||||
@Suppress("FunctionName")
|
||||
fun Synchronizer(
|
||||
initializer: SdkSynchronizer.SdkInitializer,
|
||||
initializer: Initializer,
|
||||
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
|
||||
blockStore: CompactBlockStore = CompactBlockDbStore(initializer.context, initializer.rustBackend.pathCacheDb),
|
||||
|
|
Loading…
Reference in New Issue