Browse Source

Performance and param URL tweaks

pull/5/head
fekt 8 months ago
parent
commit
15e3f063d0
  1. 13
      sdk-lib/src/main/java/cash/z/ecc/android/sdk/ext/ZcashSdk.kt
  2. 3
      sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/SaplingParamTool.kt

13
sdk-lib/src/main/java/cash/z/ecc/android/sdk/ext/ZcashSdk.kt

@ -37,19 +37,19 @@ object ZcashSdk {
// Because blocks are buffered in memory upon download and storage into SQLite, there is an upper bound
// above which OutOfMemoryError is thrown. Experimentally, this value is below 50 blocks.
// Back of the envelope calculation says the maximum block size is ~100kb.
const val DOWNLOAD_BATCH_SIZE = 10
const val DOWNLOAD_BATCH_SIZE = 50
/**
* Default size of batches of blocks to scan via librustzcash. The smaller this number the more granular information
* can be provided about scan state. Unfortunately, it may also lead to a lot of overhead during scanning.
*/
val SCAN_BATCH_SIZE = 150
val SCAN_BATCH_SIZE = 500
/**
* Default amount of time, in milliseconds, to poll for new blocks. Typically, this should be about half the average
* block time.
*/
val POLL_INTERVAL = 20_000L
val POLL_INTERVAL = 38_000L
/**
* Estimate of the time between blocks.
@ -87,11 +87,12 @@ object ZcashSdk {
val OUTPUT_PARAM_FILE_NAME = "sapling-output.params"
/**
* The Url that is used by default in zcashd.
* The Url that is used by default in hushd.
* We'll want to make this externally configurable, rather than baking it into the SDK but
* this will do for now, since we're using a cloudfront URL that already redirects.
* this will do for now
*/
val CLOUD_PARAM_DIR_URL = "https://z.cash/downloads/"
val CLOUD_PARAM_DIR_URL = listOf("https://git.hush.is/hush/hush3/raw/branch/master/",
"https://github.com/hushmirror/hush3/raw/dev/")
/**
* The default memo to use when shielding transparent funds.

3
sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/SaplingParamTool.kt

@ -57,7 +57,8 @@ class SaplingParamTool {
ZcashSdk.SPEND_PARAM_FILE_NAME,
ZcashSdk.OUTPUT_PARAM_FILE_NAME
).forEach { paramFileName ->
val url = "${ZcashSdk.CLOUD_PARAM_DIR_URL}/$paramFileName"
val url = "${ZcashSdk.CLOUD_PARAM_DIR_URL.random()}/$paramFileName"
twig("Downloading Sapling params from ${url}...")
val request = Request.Builder().url(url).build()
val response = withContext(Dispatchers.IO) { client.newCall(request).execute() }
if (response.isSuccessful) {

Loading…
Cancel
Save