From aadcc73906152f0000f5048a49b099d1b9fb5b61 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 8 May 2025 09:59:03 -0300 Subject: [PATCH] adapt to since and until not being pointers. --- bunker.go | 3 +-- count.go | 15 +++++++-------- go.mod | 2 +- go.sum | 2 -- helpers_key.go | 4 ++-- nostrfs/viewdir.go | 12 ++++++------ req.go | 7 ++----- wallet.go | 2 +- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/bunker.go b/bunker.go index cafce16..ff5169c 100644 --- a/bunker.go +++ b/bunker.go @@ -140,11 +140,10 @@ var bunker = &cli.Command{ printBunkerInfo() // subscribe to relays - now := nostr.Now() events := sys.Pool.SubscribeMany(ctx, relayURLs, nostr.Filter{ Kinds: []nostr.Kind{nostr.KindNostrConnect}, Tags: nostr.TagMap{"p": []string{pubkey.Hex()}}, - Since: &now, + Since: nostr.Now(), LimitZero: true, }, nostr.SubscriptionOptions{ Label: "nak-bunker", diff --git a/count.go b/count.go index bad4b8e..f22ecb8 100644 --- a/count.go +++ b/count.go @@ -46,13 +46,13 @@ var count = &cli.Command{ Usage: "shortcut for --tag p=", Category: CATEGORY_FILTER_ATTRIBUTES, }, - &cli.IntFlag{ + &NaturalTimeFlag{ Name: "since", Aliases: []string{"s"}, Usage: "only accept events newer than this (unix timestamp)", Category: CATEGORY_FILTER_ATTRIBUTES, }, - &cli.IntFlag{ + &NaturalTimeFlag{ Name: "until", Aliases: []string{"u"}, Usage: "only accept events older than this (unix timestamp)", @@ -122,14 +122,13 @@ var count = &cli.Command{ } } - if since := c.Int("since"); since != 0 { - ts := nostr.Timestamp(since) - filter.Since = &ts + if c.IsSet("since") { + filter.Since = getNaturalDate(c, "since") } - if until := c.Int("until"); until != 0 { - ts := nostr.Timestamp(until) - filter.Until = &ts + if c.IsSet("until") { + filter.Until = getNaturalDate(c, "until") } + if limit := c.Int("limit"); limit != 0 { filter.Limit = int(limit) } diff --git a/go.mod b/go.mod index 1d53d7e..ef35812 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/mailru/easyjson v0.9.0 github.com/mark3labs/mcp-go v0.8.3 github.com/markusmobius/go-dateparser v1.2.3 + github.com/mattn/go-tty v0.0.7 github.com/stretchr/testify v1.10.0 github.com/urfave/cli/v3 v3.0.0-beta1 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 @@ -59,7 +60,6 @@ require ( github.com/magefile/mage v1.14.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-tty v0.0.7 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/go.sum b/go.sum index 3c5965f..4206862 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= fiatjaf.com/lib v0.3.1 h1:/oFQwNtFRfV+ukmOCxfBEAuayoLwXp4wu2/fz5iHpwA= fiatjaf.com/lib v0.3.1/go.mod h1:Ycqq3+mJ9jAWu7XjbQI1cVr+OFgnHn79dQR5oTII47g= -fiatjaf.com/nostr v0.0.0-20250506031545-0d99789a54e2 h1:WDjFQ8hPUAvTDKderZ0NC6vaRBBxODPchKER4wuQdG8= -fiatjaf.com/nostr v0.0.0-20250506031545-0d99789a54e2/go.mod h1:VPs38Fc8J1XAErV750CXAmMUqIq3XEX9VZVj/LuQzzM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc= github.com/FastFilter/xorfilter v0.2.1/go.mod h1:aumvdkhscz6YBZF9ZA/6O4fIoNod4YR50kIVGGZ7l9I= diff --git a/helpers_key.go b/helpers_key.go index ccccc8b..ad7a33f 100644 --- a/helpers_key.go +++ b/helpers_key.go @@ -50,10 +50,10 @@ func gatherKeyerFromArguments(ctx context.Context, c *cli.Command) (nostr.Keyer, if bunker != nil { kr = keyer.NewBunkerSignerFromBunkerClient(bunker) } else { - kr, err = keyer.NewPlainKeySigner(key) + kr = keyer.NewPlainKeySigner(key) } - return kr, key, err + return kr, key, nil } func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (nostr.SecretKey, *nip46.BunkerClient, error) { diff --git a/nostrfs/viewdir.go b/nostrfs/viewdir.go index cc094e2..de3afba 100644 --- a/nostrfs/viewdir.go +++ b/nostrfs/viewdir.go @@ -183,8 +183,8 @@ func (n *ViewDir) publishNote() { func (n *ViewDir) Getattr(_ context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno { now := nostr.Now() - if n.filter.Until != nil { - now = *n.filter.Until + if n.filter.Until != 0 { + now = n.filter.Until } aMonthAgo := now - 30*24*60*60 out.Mtime = uint64(aMonthAgo) @@ -199,14 +199,14 @@ func (n *ViewDir) Opendir(ctx context.Context) syscall.Errno { if n.paginate { now := nostr.Now() - if n.filter.Until != nil { - now = *n.filter.Until + if n.filter.Until != 0 { + now = n.filter.Until } aMonthAgo := now - 30*24*60*60 - n.filter.Since = &aMonthAgo + n.filter.Since = aMonthAgo filter := n.filter - filter.Until = &aMonthAgo + filter.Until = aMonthAgo n.AddChild("@previous", n.NewPersistentInode( n.root.ctx, diff --git a/req.go b/req.go index c1fec94..9b73a9c 100644 --- a/req.go +++ b/req.go @@ -286,13 +286,10 @@ func applyFlagsToFilter(c *cli.Command, filter *nostr.Filter) error { } if c.IsSet("since") { - nts := getNaturalDate(c, "since") - filter.Since = &nts + filter.Since = getNaturalDate(c, "since") } - if c.IsSet("until") { - nts := getNaturalDate(c, "until") - filter.Until = &nts + filter.Until = getNaturalDate(c, "until") } if limit := c.Uint("limit"); limit != 0 { diff --git a/wallet.go b/wallet.go index cc73424..414d03e 100644 --- a/wallet.go +++ b/wallet.go @@ -240,7 +240,7 @@ var wallet = &cli.Command{ if mint := c.String("mint"); mint != "" { sourceMint = "http" + nostr.NormalizeURL(mint)[2:] } - proofs, mint, err := w.Send(ctx, amount, nip60.SendOptions{ + proofs, mint, err := w.SendInternal(ctx, amount, nip60.SendOptions{ SpecificSourceMint: sourceMint, }) if err != nil {