deprecate all useless tag methods, implement Find() and friends.

This commit is contained in:
fiatjaf
2025-03-10 02:33:29 -03:00
parent 99b11ea3be
commit a52165fb7d
6 changed files with 90 additions and 75 deletions

View File

@@ -24,9 +24,9 @@ var (
// if the target is bigger than the actual difficulty then it returns 0.
func CommittedDifficulty(event *nostr.Event) int {
work := 0
if nonceTag := event.Tags.GetFirst([]string{"nonce", ""}); nonceTag != nil && len(*nonceTag) >= 3 {
if nonceTag := event.Tags.Find("nonce"); nonceTag != nil && len(nonceTag) >= 3 {
work = Difficulty(event.ID)
target, _ := strconv.Atoi((*nonceTag)[2])
target, _ := strconv.Atoi(nonceTag[2])
if target <= work {
work = target
} else {