--pow: parallel work.

This commit is contained in:
fiatjaf 2024-08-20 23:06:14 -03:00
parent 0240866fa1
commit 014c6bc11d
3 changed files with 7 additions and 5 deletions

View File

@ -269,8 +269,10 @@ example:
evt.PubKey, _ = nostr.GetPublicKey(sec) evt.PubKey, _ = nostr.GetPublicKey(sec)
} }
// try to generate work with this difficulty -- essentially forever // try to generate work with this difficulty -- runs forever
nip13.Generate(&evt, int(difficulty), time.Hour*24*365) nonceTag, _ := nip13.DoWork(ctx, evt, int(difficulty))
evt.Tags = append(evt.Tags, nonceTag)
mustRehashAndResign = true mustRehashAndResign = true
} }

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/fiatjaf/khatru v0.7.5 github.com/fiatjaf/khatru v0.7.5
github.com/mailru/easyjson v0.7.7 github.com/mailru/easyjson v0.7.7
github.com/markusmobius/go-dateparser v1.2.3 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 github.com/nbd-wtf/nostr-sdk v0.5.0
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 golang.org/x/exp v0.0.0-20240707233637-46b078467d37
) )

4
go.sum
View File

@ -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.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 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 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.9 h1:kM/+nCEKEUwHT9LhSPnS1ucS9yYG6t5VkxlYdXdMchU=
github.com/nbd-wtf/go-nostr v0.34.8/go.mod h1:NZQkxl96ggbO8rvDpVjcsojJqKTPwqhP4i82O7K5DJs= 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 h1:zrMxcvMSxkw29RyfXEdF3XW5rUWLuT5Q9oBAhd5dyew=
github.com/nbd-wtf/nostr-sdk v0.5.0/go.mod h1:MJ7gYv3XiZKU6MHSM0N7oHqQAQhbvpgGQk4Q+XUdIUs= 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= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=