Fix header sync and recovery handling
This commit is contained in:
parent
207657fe13
commit
e0e2a65d1c
4 changed files with 43 additions and 13 deletions
|
|
@ -22,8 +22,8 @@ android {
|
||||||
applicationId = "org.vextaproject.wallet"
|
applicationId = "org.vextaproject.wallet"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 33
|
versionCode = 35
|
||||||
versionName = "0.6.3"
|
versionName = "0.6.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,13 @@ object HeaderSync {
|
||||||
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
||||||
val count = readCompactSize(buffer)
|
val count = readCompactSize(buffer)
|
||||||
|
|
||||||
if (count > 2000) {
|
val maximumPossibleHeaders =
|
||||||
throw IllegalStateException("too many headers: $count")
|
buffer.remaining() / 81
|
||||||
|
|
||||||
|
if (count < 0 || count > maximumPossibleHeaders) {
|
||||||
|
throw IllegalStateException(
|
||||||
|
"invalid headers count: $count"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
repeat(count) {
|
repeat(count) {
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ class MainActivity : Activity() {
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (intent.getBooleanExtra("sync_only", false)) {
|
if (intent.getBooleanExtra("sync_only", false)) {
|
||||||
|
if (chain.last().height > 0) {
|
||||||
setResult(
|
setResult(
|
||||||
RESULT_OK,
|
RESULT_OK,
|
||||||
android.content.Intent().putExtra(
|
android.content.Intent().putExtra(
|
||||||
|
|
@ -155,6 +156,15 @@ class MainActivity : Activity() {
|
||||||
chain.last().height
|
chain.last().height
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
setResult(
|
||||||
|
RESULT_CANCELED,
|
||||||
|
android.content.Intent().putExtra(
|
||||||
|
"sync_error",
|
||||||
|
results.joinToString("\n\n")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
status.text =
|
status.text =
|
||||||
|
|
@ -317,8 +327,13 @@ class MainActivity : Activity() {
|
||||||
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
||||||
val count = readCompactSize(buffer)
|
val count = readCompactSize(buffer)
|
||||||
|
|
||||||
if (count > 2000) {
|
val maximumPossibleHeaders =
|
||||||
throw IllegalStateException("too many headers: $count")
|
buffer.remaining() / 81
|
||||||
|
|
||||||
|
if (count < 0 || count > maximumPossibleHeaders) {
|
||||||
|
throw IllegalStateException(
|
||||||
|
"invalid headers count: $count"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
repeat(count) {
|
repeat(count) {
|
||||||
|
|
|
||||||
|
|
@ -871,8 +871,18 @@ class WalletActivity : FragmentActivity() {
|
||||||
runBlockchainScan()
|
runBlockchainScan()
|
||||||
} else {
|
} else {
|
||||||
blockchainScanRunning = false
|
blockchainScanRunning = false
|
||||||
|
|
||||||
|
val syncError = data?.getStringExtra(
|
||||||
|
"sync_error"
|
||||||
|
)?.trim()
|
||||||
|
|
||||||
blockchainScanStatus?.text =
|
blockchainScanStatus?.text =
|
||||||
|
if (syncError.isNullOrBlank()) {
|
||||||
"Block-header synchronization failed."
|
"Block-header synchronization failed."
|
||||||
|
} else {
|
||||||
|
"Block-header synchronization failed:\n" +
|
||||||
|
syncError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue