mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Renames PoW processor to parser
This commit is contained in:
parent
06c7ea0123
commit
67106e8a11
@ -26,24 +26,24 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class PoWRankParserTest {
|
||||
class PoWRankProcessorTest {
|
||||
@Test
|
||||
fun setPoW() {
|
||||
assertEquals(26, PoWRankParser.calculatePowRankOf("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e"))
|
||||
assertEquals(26, PoWRankProcessor.calculatePowRankOf("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setPoWIfCommited25() {
|
||||
assertEquals(25, PoWRankParser.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 25))
|
||||
assertEquals(25, PoWRankProcessor.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 25))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setPoWIfCommited26() {
|
||||
assertEquals(26, PoWRankParser.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 26))
|
||||
assertEquals(26, PoWRankProcessor.compute("00000026c91e9fc75fdb95b367776e2594b931cebda6d5ca3622501006669c9e", 26))
|
||||
}
|
||||
|
||||
@Test
|
||||
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
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Tag
|
||||
@ -66,7 +67,10 @@ data class PTag(
|
||||
@JvmStatic
|
||||
fun parseKey(tag: Array<String>): HexKey? {
|
||||
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]
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip13Pow
|
||||
|
||||
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()
|
||||
|
||||
@ -34,7 +34,7 @@ fun Event.hasPoWTag() = tags.hasPoW()
|
||||
fun Event.strongPoWOrNull(min: Int = 20): Int? {
|
||||
val commitment = tags.commitedPoW()
|
||||
if (commitment != null) {
|
||||
val pow = PoWRankParser.compute(id, commitment)
|
||||
val pow = PoWRankProcessor.compute(id, commitment)
|
||||
if (pow >= min) {
|
||||
return pow
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip13Pow
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.HexKey
|
||||
|
||||
class PoWRankParser {
|
||||
class PoWRankProcessor {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun compute(
|
Loading…
x
Reference in New Issue
Block a user