From 2988c71ccba5a5a7028e36cd5d6032d95b0dfb53 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 26 Sep 2024 22:17:31 -0300 Subject: [PATCH] nak/b and nak/s user-agents. --- go.mod | 2 +- go.sum | 4 ++-- helpers.go | 7 +++++++ paginate.go | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 384eea4..2ecd18e 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,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.37.2 + github.com/nbd-wtf/go-nostr v0.37.5 golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 ) diff --git a/go.sum b/go.sum index b3c3565..f64d5e8 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.37.2 h1:42rriFqqz07EdydERwYeQnewl+Rah1Gq46I+Wh0KYYg= -github.com/nbd-wtf/go-nostr v0.37.2/go.mod h1:TGKGj00BmJRXvRe0LlpDN3KKbELhhPXgBwUEhzu3Oq0= +github.com/nbd-wtf/go-nostr v0.37.5 h1:w/8aBgSf3lC2OoqAJXnYUO0Nxqv+YAdxDC8X3FbLYS8= +github.com/nbd-wtf/go-nostr v0.37.5/go.mod h1:TGKGj00BmJRXvRe0LlpDN3KKbELhhPXgBwUEhzu3Oq0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/helpers.go b/helpers.go index d8eb013..f84967f 100644 --- a/helpers.go +++ b/helpers.go @@ -18,6 +18,12 @@ import ( var sys = sdk.NewSystem() +func init() { + sys.Pool = nostr.NewSimplePool(context.Background(), + nostr.WithUserAgent("nak/b"), + ) +} + const ( LINE_PROCESSING_ERROR = iota ) @@ -123,6 +129,7 @@ func connectToAllRelays( append(opts, nostr.WithEventMiddleware(sys.TrackEventHints), nostr.WithPenaltyBox(), + nostr.WithUserAgent("nak/s"), )..., ) diff --git a/paginate.go b/paginate.go index 77ee9a7..0f871e3 100644 --- a/paginate.go +++ b/paginate.go @@ -12,8 +12,8 @@ import ( func paginateWithParams( interval time.Duration, globalLimit uint64, -) func(ctx context.Context, urls []string, filters nostr.Filters) chan nostr.RelayEvent { - return func(ctx context.Context, urls []string, filters nostr.Filters) chan nostr.RelayEvent { +) func(ctx context.Context, urls []string, filters nostr.Filters, opts ...nostr.SubscriptionOption) chan nostr.RelayEvent { + return func(ctx context.Context, urls []string, filters nostr.Filters, opts ...nostr.SubscriptionOption) chan nostr.RelayEvent { // filters will always be just one filter := filters[0] @@ -42,7 +42,7 @@ func paginateWithParams( time.Sleep(interval) keepGoing := false - for evt := range sys.Pool.SubManyEose(ctx, urls, nostr.Filters{filter}) { + for evt := range sys.Pool.SubManyEose(ctx, urls, nostr.Filters{filter}, opts...) { if slices.Contains(repeatedCache, evt.ID) { continue }