Skip to content

Commit

Permalink
fix: eliminate another sync stuck at 31% (#1327)
Browse files Browse the repository at this point in the history
* feat: show platform version on AboutActivity

* chore: update to dashj 21.1.3-SNAPSHOT

* refactor: update based on changes to dash-sdk-kotlin

* fix: update copyright year to 2024

* fix: add DPP_VERSION to BuildConfig
  • Loading branch information
HashEngineering authored Nov 26, 2024
1 parent d3ebfe3 commit 5b800c5
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
kotlin_version = '1.9.23'
coroutinesVersion = '1.6.4'
ok_http_version = '4.9.1'
dashjVersion = '21.1.2'
dashjVersion = '21.1.3-SNAPSHOT'
dppVersion = "1.5.1-SNAPSHOT"
hiltVersion = '2.51'
hiltCompilerVersion = '1.2.0'
Expand Down
1 change: 1 addition & 0 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ android {
} else if(System.getenv("SUPPORT_EMAIL") != null) {
buildConfigField("String", "SUPPORT_EMAIL", "\"${System.getenv("SUPPORT_EMAIL")}\"")
}
buildConfigField("String", "DPP_VERSION", "\"$dppVersion\"")
}

buildTypes {
Expand Down
8 changes: 8 additions & 0 deletions wallet/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
android:layout_marginHorizontal="20dp"
tools:text="DashJ 21.1.0" />

<TextView
android:id="@+id/platform_version_name"
style="@style/Body2.Tertiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
tools:text="Platform 1.5.1" />

<LinearLayout
android:id="@+id/about_content"
style="@style/ViewRaised"
Expand Down
2 changes: 1 addition & 1 deletion wallet/res/values/strings-extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<string name="about_review_and_rate">Review and rate the app</string>
<string name="about_contact_support">Contact Support</string>
<string name="about_fork_disclaimer">This is an open source app forked from Bitcoin Wallet</string>
<string name="about_copyright">Copyright © 2023 Dash Core Group</string>
<string name="about_copyright">Copyright © 2024 Dash Core Group</string>
<string name="about_license">GNU General Public License v3.0</string>
<string name="about_github_link" translatable="false">https://github.com/dashevo/dash-wallet</string>
<string name="about_version_name">DashPay Wallet %s</string>
Expand Down
1 change: 1 addition & 0 deletions wallet/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
<string name="about_source_title">Source code</string>
<string name="about_category_credits">This app is using…</string>
<string name="about_credits_bitcoinj_title">dashj %s, a Dash protocol implementation</string>
<string name="about_credits_platform_title" translatable="false">Platform %s</string>
<string name="about_credits_zxing_title">ZXing, a QR-code processing library</string>
<string name="about_credits_icon_title">This app is using an icon by \'bitboy\'</string>
<string name="about_credits_scrypt_title">Scrypt, implemented by Will Glozer and Colin Percival</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1068,17 +1068,7 @@ class PlatformSynchronizationService @Inject constructor(
try {
val name :String? = when (votePoll) {
is ContestedDocumentResourceVotePoll -> {
when (votePoll.indexValues[1]) {
is String -> votePoll.indexValues[1] as String
is PlatformValue -> {
val value = votePoll.indexValues[1] as PlatformValue
when (value.tag) {
PlatformValue.Tag.Text -> value.text
else -> null
}
}
else -> null
}
votePoll.indexValues[1]
}
else -> null
}
Expand All @@ -1089,7 +1079,7 @@ class PlatformSynchronizationService @Inject constructor(
voteContender.map.forEach { (identifier, contender) ->

if (voteContender.winner.isEmpty) {
val contestedDocument = contender.seralizedDocument?.let { serialized ->
val contestedDocument = contender.serializedDocument?.let { serialized ->
DomainDocument(
platform.platform.names.deserialize(serialized)
)
Expand Down Expand Up @@ -1173,7 +1163,7 @@ class PlatformSynchronizationService @Inject constructor(

voteContender.map.forEach { (identifier, contender) ->

val contestedDocument = contender.seralizedDocument?.let { serialized ->
val contestedDocument = contender.serializedDocument?.let { serialized ->
DomainDocument(
platform.platform.names.deserialize(serialized)
)
Expand Down Expand Up @@ -1226,7 +1216,7 @@ class PlatformSynchronizationService @Inject constructor(
val voteContender = platformRepo.getVoteContenders(name)

voteContender.map.forEach { (identifier, contender) ->
val contestedDocument = contender.seralizedDocument?.let { serialized ->
val contestedDocument = contender.serializedDocument?.let { serialized ->
DomainDocument(
platform.platform.names.deserialize(serialized)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class CreateIdentityService : LifecycleService() {
?: error("${blockchainIdentityData.username} does not have ${blockchainIdentity.uniqueIdentifier} as a contender")

val document = DomainDocument(
platformRepo.platform.names.deserialize(documentWithVotes.seralizedDocument!!)
platformRepo.platform.names.deserialize(documentWithVotes.serializedDocument!!)
)

usernameRequestDao.insert(
Expand All @@ -691,7 +691,7 @@ class CreateIdentityService : LifecycleService() {

// determine when voting started by finding the minimum timestamp
val earliestCreatedAt = contenders.map.values.minOf {
val document = platformRepo.platform.names.deserialize(documentWithVotes.seralizedDocument!!)
val document = platformRepo.platform.names.deserialize(documentWithVotes.serializedDocument!!)
document.createdAt ?: 0
}

Expand Down Expand Up @@ -904,7 +904,7 @@ class CreateIdentityService : LifecycleService() {
var label = name
if (winner.isEmpty) {
val contestedDocument = DomainDocument(
platformRepo.platform.names.deserialize(documentWithVotes.seralizedDocument!!)
platformRepo.platform.names.deserialize(documentWithVotes.serializedDocument!!)
)
blockchainIdentity.currentUsername = contestedDocument.label
votingStartedAt = contestedDocument.createdAt!!
Expand Down Expand Up @@ -946,7 +946,7 @@ class CreateIdentityService : LifecycleService() {

// determine when voting started by finding the minimum timestamp
val earliestCreatedAt = voteContenders.map.values.minOf {
val document = platformRepo.platform.names.deserialize(documentWithVotes.seralizedDocument!!)
val document = platformRepo.platform.names.deserialize(documentWithVotes.serializedDocument!!)
document.createdAt ?: 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,39 +124,20 @@ class BroadcastUsernameVotesWorker @AssistedInject constructor(
// update local database
analytics.logEvent(AnalyticsConstants.UsernameVoting.VOTE_SUCCESS, mapOf())
val arrayOfnames: Array<String> = votingResults.map {
val item = ((it.second?.resourceVote?.votePoll as? ContestedDocumentResourceVotePoll)?.indexValues?.get(1) ?: "null")
when (item) {
is PlatformValue -> {
when (item.tag) {
PlatformValue.Tag.Text -> item.text
else -> item.toString()
}
}
is String -> item
else -> item.toString()
}
((it.second?.resourceVote?.votePoll as? ContestedDocumentResourceVotePoll)?.indexValues?.get(1) ?: "null")
}.toSet().toTypedArray()
val votes = hashMapOf<String, UsernameVote>()
votingResults.forEach {
when (val votePoll = it.second?.resourceVote?.votePoll as? ContestedDocumentResourceVotePoll) {
is ContestedDocumentResourceVotePoll -> {
val normalizedLabel = when (val item = votePoll?.indexValues?.get(1)) {
is PlatformValue -> {
when (item.tag) {
PlatformValue.Tag.Text -> item.text
else -> null
}
}
is String -> item
else -> null
}
val normalizedLabel = votePoll.indexValues[1]
val identity = when (it.first) {
is TowardsIdentity -> {
(it.first as TowardsIdentity).identifier
}
else -> null
}
votes[normalizedLabel!!] = UsernameVote(normalizedLabel, identity.toString(), it.first)
votes[normalizedLabel] = UsernameVote(normalizedLabel, identity.toString(), it.first)
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion wallet/src/de/schildbach/wallet/ui/more/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package de.schildbach.wallet.ui.more
import android.annotation.SuppressLint
import android.content.*
import android.content.Intent.ACTION_VIEW
import android.content.pm.PackageManager
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
Expand Down Expand Up @@ -49,6 +50,7 @@ import org.slf4j.LoggerFactory
import kotlin.math.pow
import kotlin.math.sqrt


@AndroidEntryPoint
class AboutActivity : LockScreenActivity(), SensorEventListener {
// variables for shake detection
Expand Down Expand Up @@ -79,7 +81,10 @@ class AboutActivity : LockScreenActivity(), SensorEventListener {
R.string.about_credits_bitcoinj_title,
VersionMessage.BITCOINJ_VERSION
)

binding.platformVersionName.text = getString(
R.string.about_credits_platform_title,
BuildConfig.DPP_VERSION
)
binding.githubLink.setOnClickListener {
val i = Intent(ACTION_VIEW)
i.data = Uri.parse(binding.githubLink.text.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class RequestUserNameViewModel @Inject constructor(
var maxApprovalVotes = 0
firstCreatedAt = try {
contenders.map.values.minOf { contender ->
val document = contender.seralizedDocument?.let {
val document = contender.serializedDocument?.let {
DomainDocument(platformRepo.platform.names.deserialize(it))
}
maxApprovalVotes = max(contender.votes, maxApprovalVotes)
Expand Down

0 comments on commit 5b800c5

Please sign in to comment.