From 014c6bc11dd2a8ea763214984a4317773ed495e2 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 20 Aug 2024 23:06:14 -0300 Subject: [PATCH] --pow: parallel work. --- event.go | 6 ++++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/event.go b/event.go index cedb0b8..10dec32 100644 --- a/event.go +++ b/event.go @@ -269,8 +269,10 @@ example: evt.PubKey, _ = nostr.GetPublicKey(sec) } - // try to generate work with this difficulty -- essentially forever - nip13.Generate(&evt, int(difficulty), time.Hour*24*365) + // try to generate work with this difficulty -- runs forever + nonceTag, _ := nip13.DoWork(ctx, evt, int(difficulty)) + evt.Tags = append(evt.Tags, nonceTag) + mustRehashAndResign = true } diff --git a/go.mod b/go.mod index 2ca87ff..c8c5956 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/fiatjaf/khatru v0.7.5 github.com/mailru/easyjson v0.7.7 github.com/markusmobius/go-dateparser v1.2.3 - github.com/nbd-wtf/go-nostr v0.34.8 + github.com/nbd-wtf/go-nostr v0.34.9 github.com/nbd-wtf/nostr-sdk v0.5.0 golang.org/x/exp v0.0.0-20240707233637-46b078467d37 ) diff --git a/go.sum b/go.sum index 2142d98..b79c403 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/nbd-wtf/go-nostr v0.34.8 h1:wExcoeaFX5DZKzZruQlrEYVd59Z6GmRyPCltTuoyn9g= -github.com/nbd-wtf/go-nostr v0.34.8/go.mod h1:NZQkxl96ggbO8rvDpVjcsojJqKTPwqhP4i82O7K5DJs= +github.com/nbd-wtf/go-nostr v0.34.9 h1:kM/+nCEKEUwHT9LhSPnS1ucS9yYG6t5VkxlYdXdMchU= +github.com/nbd-wtf/go-nostr v0.34.9/go.mod h1:NZQkxl96ggbO8rvDpVjcsojJqKTPwqhP4i82O7K5DJs= github.com/nbd-wtf/nostr-sdk v0.5.0 h1:zrMxcvMSxkw29RyfXEdF3XW5rUWLuT5Q9oBAhd5dyew= github.com/nbd-wtf/nostr-sdk v0.5.0/go.mod h1:MJ7gYv3XiZKU6MHSM0N7oHqQAQhbvpgGQk4Q+XUdIUs= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=