Renames PoW processor to parser

This commit is contained in:
Vitor Pamplona
2025-02-16 11:53:23 -05:00
parent 06c7ea0123
commit 67106e8a11
4 changed files with 13 additions and 9 deletions
@@ -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(