Renames PoW processor to parser
This commit is contained in:
+5
-5
@@ -26,24 +26,24 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class PoWRankParserTest {
|
class PoWRankProcessorTest {
|
||||||
@Test
|
@Test
|
||||||
fun setPoW() {
|
fun setPoW() {
|
||||||
assertEquals(26, PoWRankParser.calculatePowRankOf("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e"))
|
assertEquals(26, PoWRankProcessor.calculatePowRankOf("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setPoWIfCommited25() {
|
fun setPoWIfCommited25() {
|
||||||
assertEquals(25, PoWRankParser.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 25))
|
assertEquals(25, PoWRankProcessor.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 25))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setPoWIfCommited26() {
|
fun setPoWIfCommited26() {
|
||||||
assertEquals(26, PoWRankParser.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 26))
|
assertEquals(26, PoWRankProcessor.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 26))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun setPoWIfCommited27() {
|
fun setPoWIfCommited27() {
|
||||||
assertEquals(26, PoWRankParser.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 27))
|
assertEquals(26, PoWRankProcessor.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 27))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.nip01Core.tags.people
|
package com.vitorpamplona.quartz.nip01Core.tags.people
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Tag
|
import com.vitorpamplona.quartz.nip01Core.core.Tag
|
||||||
@@ -66,7 +67,10 @@ data class PTag(
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun parseKey(tag: Array<String>): HexKey? {
|
fun parseKey(tag: Array<String>): HexKey? {
|
||||||
if (tag.isNotName(TAG_NAME, TAG_SIZE)) return null
|
if (tag.isNotName(TAG_NAME, TAG_SIZE)) return null
|
||||||
if (tag[1].length != 64) return null
|
if (tag[1].length != 64) {
|
||||||
|
Log.w("PTag", "Invalid `$TAG_NAME` value ${tag.joinToString(", ")}")
|
||||||
|
return null
|
||||||
|
}
|
||||||
return tag[1]
|
return tag[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip13Pow
|
|||||||
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
|
|
||||||
fun Event.pow() = PoWRankParser.compute(id, tags.commitedPoW())
|
fun Event.pow() = PoWRankProcessor.compute(id, tags.commitedPoW())
|
||||||
|
|
||||||
fun Event.hasPoWTag() = tags.hasPoW()
|
fun Event.hasPoWTag() = tags.hasPoW()
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ fun Event.hasPoWTag() = tags.hasPoW()
|
|||||||
fun Event.strongPoWOrNull(min: Int = 20): Int? {
|
fun Event.strongPoWOrNull(min: Int = 20): Int? {
|
||||||
val commitment = tags.commitedPoW()
|
val commitment = tags.commitedPoW()
|
||||||
if (commitment != null) {
|
if (commitment != null) {
|
||||||
val pow = PoWRankParser.compute(id, commitment)
|
val pow = PoWRankProcessor.compute(id, commitment)
|
||||||
if (pow >= min) {
|
if (pow >= min) {
|
||||||
return pow
|
return pow
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip13Pow
|
|||||||
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||||
|
|
||||||
class PoWRankParser {
|
class PoWRankProcessor {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun compute(
|
fun compute(
|
||||||
Reference in New Issue
Block a user