update go-nostr to get relay information from pool.

This commit is contained in:
fiatjaf
2023-10-02 09:24:02 -03:00
parent 28ddb1cefd
commit 08c16d371c
3 changed files with 13 additions and 16 deletions

5
go.mod
View File

@@ -9,12 +9,11 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/lukevers/freetype-go v0.0.0-20150513150840-77e276735410
github.com/microcosm-cc/bluemonday v1.0.24
github.com/nbd-wtf/go-nostr v0.20.0
github.com/nbd-wtf/go-nostr v0.23.1
github.com/pelletier/go-toml v1.9.5
github.com/rs/cors v1.10.0
github.com/rs/zerolog v1.29.1
golang.org/x/exp v0.0.0-20221106115401-f9659909a136
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
mvdan.cc/xurls/v2 v2.5.0
)
@@ -40,7 +39,7 @@ require (
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/puzpuzpuz/xsync v1.5.2 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.0 // indirect
github.com/stretchr/testify v1.7.5 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect

10
go.sum
View File

@@ -113,8 +113,8 @@ github.com/microcosm-cc/bluemonday v1.0.24 h1:NGQoPtwGVcbGkKfvyYk1yRqknzBuoMiUrO
github.com/microcosm-cc/bluemonday v1.0.24/go.mod h1:ArQySAMps0790cHSkdPEJ7bGkF2VePWH773hsJNSHf8=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/nbd-wtf/go-nostr v0.20.0 h1:97SYhg68jWh5G1bW1g454hA0dTV7btwtPg836n4no0o=
github.com/nbd-wtf/go-nostr v0.20.0/go.mod h1:iFfiZr8YYSC1vmdUei0VfDB7GH/RjS3cbmiD1I5BKyo=
github.com/nbd-wtf/go-nostr v0.23.1 h1:O2zHqPfGosbqBSGzwzL7S7zzJt57rY9HIKCMWIr2Lps=
github.com/nbd-wtf/go-nostr v0.23.1/go.mod h1:eE8Qf8QszZbCd9arBQyotXqATNUElWsTEEx+LLORhyQ=
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=
@@ -132,8 +132,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/puzpuzpuz/xsync v1.5.2 h1:yRAP4wqSOZG+/4pxJ08fPTwrfL0IzE/LKQ/cw509qGY=
github.com/puzpuzpuz/xsync v1.5.2/go.mod h1:K98BYhX3k1dQ2M63t1YNVDanbwUPmBCAhNmVrrxfiGg=
github.com/puzpuzpuz/xsync/v2 v2.5.0 h1:2k4qrO/orvmEXZ3hmtHqIy9XaQtPTwzMZk1+iErpE8c=
github.com/puzpuzpuz/xsync/v2 v2.5.0/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU=
github.com/rs/cors v1.10.0 h1:62NOS1h+r8p1mW6FM0FSB0exioXLhd/sh15KpjWBZ+8=
github.com/rs/cors v1.10.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
@@ -172,8 +172,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20221106115401-f9659909a136 h1:Fq7F/w7MAa1KJ5bt2aJ62ihqp9HDcRuyILskkpIAurw=
golang.org/x/exp v0.0.0-20221106115401-f9659909a136/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=

View File

@@ -131,14 +131,14 @@ func getEvent(ctx context.Context, code string) (*nostr.Event, error) {
relays = unique(relays)
ctx, cancel := context.WithTimeout(ctx, time.Second*8)
defer cancel()
if evt := pool.QuerySingle(ctx, relays, filter); evt != nil {
b, err := json.Marshal(evt)
if ie := pool.QuerySingle(ctx, relays, filter); ie.Event != nil {
b, err := json.Marshal(ie.Event)
if err != nil {
log.Error().Err(err).Stringer("event", evt).Msg("error marshaling nson")
return evt, nil
log.Error().Err(err).Stringer("event", ie.Event).Msg("error marshaling nson")
return ie.Event, nil
}
cache.SetWithTTL(code, []byte(b), time.Hour*24*7)
return evt, nil
return ie.Event, nil
}
return nil, fmt.Errorf("couldn't find this %s", prefix)
@@ -175,11 +175,11 @@ func getLastNotes(ctx context.Context, code string, limit int) []*nostr.Event {
lastNotes := make([]*nostr.Event, 0, 20)
for {
select {
case evt, more := <-ch:
case ie, more := <-ch:
if !more {
goto end
}
lastNotes = append(lastNotes, evt)
lastNotes = append(lastNotes, ie.Event)
case <-ctx.Done():
goto end
}