mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
move sdk out to its own module.
This commit is contained in:
parent
5847335506
commit
1789d43d51
23
go.mod
23
go.mod
@ -3,36 +3,37 @@ module github.com/nbd-wtf/go-nostr
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3
|
||||
github.com/dgraph-io/ristretto v0.1.1
|
||||
github.com/gobwas/httphead v0.1.0
|
||||
github.com/gobwas/ws v1.2.0
|
||||
github.com/mailru/easyjson v0.7.7
|
||||
github.com/puzpuzpuz/xsync/v2 v2.5.0
|
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
github.com/tyler-smith/go-bip32 v1.0.0
|
||||
github.com/tyler-smith/go-bip39 v1.1.0
|
||||
golang.org/x/exp v0.0.0-20221106115401-f9659909a136
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc
|
||||
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
|
||||
golang.org/x/net v0.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
|
||||
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
|
||||
github.com/golang/glog v1.0.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/stretchr/testify v1.8.2 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/crypto v0.7.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/dgraph-io/ristretto => github.com/aryehlev/ristretto v0.0.0-20230325112030-fd222a1ebb5e
|
||||
|
48
go.sum
48
go.sum
@ -10,15 +10,16 @@ github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tj
|
||||
github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ=
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||
@ -28,18 +29,20 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
|
||||
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
|
||||
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
@ -52,8 +55,8 @@ github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.2.0 h1:u0p9s3xLYpZCA1z5JgCkMeB34CKCMMQbM+G8Ii7YD0I=
|
||||
github.com/gobwas/ws v1.2.0/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
|
||||
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
@ -87,12 +90,17 @@ 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/v2 v2.5.0 h1:2k4qrO/orvmEXZ3hmtHqIy9XaQtPTwzMZk1+iErpE8c=
|
||||
github.com/puzpuzpuz/xsync/v2 v2.5.0/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU=
|
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=
|
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.1.5-0.20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
@ -107,16 +115,18 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C
|
||||
golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
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/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o=
|
||||
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
|
||||
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=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -127,8 +137,9 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@ -147,7 +158,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
|
||||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
|
||||
|
4
justfile
4
justfile
@ -4,8 +4,6 @@ build-all:
|
||||
echo "building $dir"
|
||||
go build "./$dir"
|
||||
end
|
||||
echo "building sdk"
|
||||
go build ./sdk
|
||||
|
||||
test-all:
|
||||
#!/usr/bin/env fish
|
||||
@ -13,5 +11,3 @@ test-all:
|
||||
echo "testing $dir"
|
||||
go test "./$dir"
|
||||
end
|
||||
echo "testing sdk"
|
||||
go test ./sdk
|
||||
|
10
sdk/cache/interface.go
vendored
10
sdk/cache/interface.go
vendored
@ -1,10 +0,0 @@
|
||||
package cache
|
||||
|
||||
import "time"
|
||||
|
||||
type Cache32[V any] interface {
|
||||
Get(k string) (v V, ok bool)
|
||||
Delete(k string)
|
||||
Set(k string, v V) bool
|
||||
SetWithTTL(k string, v V, d time.Duration) bool
|
||||
}
|
48
sdk/cache/memory/cache.go
vendored
48
sdk/cache/memory/cache.go
vendored
@ -1,48 +0,0 @@
|
||||
package cache_memory
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"time"
|
||||
|
||||
"github.com/dgraph-io/ristretto"
|
||||
)
|
||||
|
||||
type RistrettoCache[V any] struct {
|
||||
Cache *ristretto.Cache[string, V]
|
||||
}
|
||||
|
||||
func New32[V any](max int64) *RistrettoCache[V] {
|
||||
cache, _ := ristretto.NewCache(&ristretto.Config[string, V]{
|
||||
NumCounters: max * 10,
|
||||
MaxCost: max,
|
||||
BufferItems: 64,
|
||||
KeyToHash: func(key string) (uint64, uint64) { return h32(key), 0 },
|
||||
})
|
||||
return &RistrettoCache[V]{Cache: cache}
|
||||
}
|
||||
|
||||
func (s RistrettoCache[V]) Get(k string) (v V, ok bool) { return s.Cache.Get(k) }
|
||||
func (s RistrettoCache[V]) Delete(k string) { s.Cache.Del(k) }
|
||||
func (s RistrettoCache[V]) Set(k string, v V) bool { return s.Cache.Set(k, v, 1) }
|
||||
func (s RistrettoCache[V]) SetWithTTL(k string, v V, d time.Duration) bool {
|
||||
return s.Cache.SetWithTTL(k, v, 1, d)
|
||||
}
|
||||
|
||||
func h32(key string) uint64 {
|
||||
// we get an event id or pubkey as hex,
|
||||
// so just extract the last 8 bytes from it and turn them into a uint64
|
||||
return shortUint64(key)
|
||||
}
|
||||
|
||||
func shortUint64(idOrPubkey string) uint64 {
|
||||
length := len(idOrPubkey)
|
||||
if length < 8 {
|
||||
return 0
|
||||
}
|
||||
b, err := hex.DecodeString(idOrPubkey[length-8:])
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return uint64(binary.BigEndian.Uint32(b))
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package sdk
|
||||
|
||||
type Follow struct {
|
||||
Pubkey string
|
||||
Relay string
|
||||
Petname string
|
||||
}
|
63
sdk/input.go
63
sdk/input.go
@ -1,63 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip05"
|
||||
"github.com/nbd-wtf/go-nostr/nip19"
|
||||
)
|
||||
|
||||
// InputToProfile turns any npub/nprofile/hex/nip05 input into a ProfilePointer (or nil).
|
||||
func InputToProfile(ctx context.Context, input string) *nostr.ProfilePointer {
|
||||
// handle if it is a hex string
|
||||
if len(input) == 64 {
|
||||
if _, err := hex.DecodeString(input); err == nil {
|
||||
return &nostr.ProfilePointer{PublicKey: input}
|
||||
}
|
||||
}
|
||||
|
||||
// handle nip19 codes, if that's the case
|
||||
prefix, data, _ := nip19.Decode(input)
|
||||
switch prefix {
|
||||
case "npub":
|
||||
input = data.(string)
|
||||
return &nostr.ProfilePointer{PublicKey: input}
|
||||
case "nprofile":
|
||||
pp := data.(nostr.ProfilePointer)
|
||||
return &pp
|
||||
}
|
||||
|
||||
// handle nip05 ids, if that's the case
|
||||
pp, _ := nip05.QueryIdentifier(ctx, input)
|
||||
if pp != nil {
|
||||
return pp
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// InputToEventPointer turns any note/nevent/hex input into a EventPointer (or nil).
|
||||
func InputToEventPointer(input string) *nostr.EventPointer {
|
||||
// handle if it is a hex string
|
||||
if len(input) == 64 {
|
||||
if _, err := hex.DecodeString(input); err == nil {
|
||||
return &nostr.EventPointer{ID: input}
|
||||
}
|
||||
}
|
||||
|
||||
// handle nip19 codes, if that's the case
|
||||
prefix, data, _ := nip19.Decode(input)
|
||||
switch prefix {
|
||||
case "note":
|
||||
input = data.(string)
|
||||
return &nostr.EventPointer{ID: input}
|
||||
case "nevent":
|
||||
ep := data.(nostr.EventPointer)
|
||||
return &ep
|
||||
}
|
||||
|
||||
// handle nip05 ids, if that's the case
|
||||
return nil
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip19"
|
||||
)
|
||||
|
||||
type ProfileMetadata struct {
|
||||
pubkey string
|
||||
event *nostr.Event
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
DisplayName string `json:"display_name,omitempty"`
|
||||
About string `json:"about,omitempty"`
|
||||
Website string `json:"website,omitempty"`
|
||||
Picture string `json:"picture,omitempty"`
|
||||
Banner string `json:"banner,omitempty"`
|
||||
NIP05 string `json:"nip05,omitempty"`
|
||||
LUD16 string `json:"lud16,omitempty"`
|
||||
}
|
||||
|
||||
func (p ProfileMetadata) Npub() string {
|
||||
v, _ := nip19.EncodePublicKey(p.pubkey)
|
||||
return v
|
||||
}
|
||||
|
||||
func (p ProfileMetadata) Nprofile(ctx context.Context, sys *System, nrelays int) string {
|
||||
v, _ := nip19.EncodeProfile(p.pubkey, sys.FetchOutboxRelays(ctx, p.pubkey))
|
||||
return v
|
||||
}
|
||||
|
||||
func FetchProfileMetadata(ctx context.Context, pool *nostr.SimplePool, pubkey string, relays ...string) ProfileMetadata {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
ch := pool.SubManyEose(ctx, relays, nostr.Filters{
|
||||
{
|
||||
Kinds: []int{nostr.KindProfileMetadata},
|
||||
Authors: []string{pubkey},
|
||||
Limit: 1,
|
||||
},
|
||||
})
|
||||
|
||||
for ie := range ch {
|
||||
if m, err := ParseMetadata(ie.Event); err == nil {
|
||||
m.pubkey = pubkey
|
||||
m.event = ie.Event
|
||||
return *m
|
||||
}
|
||||
}
|
||||
|
||||
return ProfileMetadata{pubkey: pubkey}
|
||||
}
|
||||
|
||||
func ParseMetadata(event *nostr.Event) (*ProfileMetadata, error) {
|
||||
if event.Kind != 0 {
|
||||
return nil, fmt.Errorf("event %s is kind %d, not 0", event.ID, event.Kind)
|
||||
}
|
||||
|
||||
var meta ProfileMetadata
|
||||
if err := json.Unmarshal([]byte(event.Content), &meta); err != nil {
|
||||
cont := event.Content
|
||||
if len(cont) > 100 {
|
||||
cont = cont[0:99]
|
||||
}
|
||||
return nil, fmt.Errorf("failed to parse metadata (%s) from event %s: %w", cont, event.ID, err)
|
||||
}
|
||||
|
||||
return &meta, nil
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip19"
|
||||
)
|
||||
|
||||
type Reference struct {
|
||||
Text string
|
||||
Start int
|
||||
End int
|
||||
Profile *nostr.ProfilePointer
|
||||
Event *nostr.EventPointer
|
||||
Entity *nostr.EntityPointer
|
||||
}
|
||||
|
||||
var mentionRegex = regexp.MustCompile(`\bnostr:((note|npub|naddr|nevent|nprofile)1\w+)\b|#\[(\d+)\]`)
|
||||
|
||||
// ParseReferences parses both NIP-08 and NIP-27 references in a single unifying interface.
|
||||
func ParseReferences(evt *nostr.Event) []*Reference {
|
||||
var references []*Reference
|
||||
content := evt.Content
|
||||
|
||||
for _, ref := range mentionRegex.FindAllStringSubmatchIndex(evt.Content, -1) {
|
||||
reference := &Reference{
|
||||
Text: content[ref[0]:ref[1]],
|
||||
Start: ref[0],
|
||||
End: ref[1],
|
||||
}
|
||||
|
||||
if ref[6] == -1 {
|
||||
// didn't find a NIP-10 #[0] reference, so it's a NIP-27 mention
|
||||
nip19code := content[ref[2]:ref[3]]
|
||||
|
||||
if prefix, data, err := nip19.Decode(nip19code); err == nil {
|
||||
switch prefix {
|
||||
case "npub":
|
||||
reference.Profile = &nostr.ProfilePointer{
|
||||
PublicKey: data.(string), Relays: []string{},
|
||||
}
|
||||
case "nprofile":
|
||||
pp := data.(nostr.ProfilePointer)
|
||||
reference.Profile = &pp
|
||||
case "note":
|
||||
reference.Event = &nostr.EventPointer{ID: data.(string), Relays: []string{}}
|
||||
case "nevent":
|
||||
evp := data.(nostr.EventPointer)
|
||||
reference.Event = &evp
|
||||
case "naddr":
|
||||
addr := data.(nostr.EntityPointer)
|
||||
reference.Entity = &addr
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// it's a NIP-10 mention.
|
||||
// parse the number, get data from event tags.
|
||||
n := content[ref[6]:ref[7]]
|
||||
idx, err := strconv.Atoi(n)
|
||||
if err != nil || len(evt.Tags) <= idx {
|
||||
continue
|
||||
}
|
||||
if tag := evt.Tags[idx]; tag != nil && len(tag) >= 2 {
|
||||
switch tag[0] {
|
||||
case "p":
|
||||
relays := make([]string, 0, 1)
|
||||
if len(tag) > 2 && tag[2] != "" {
|
||||
relays = append(relays, tag[2])
|
||||
}
|
||||
reference.Profile = &nostr.ProfilePointer{
|
||||
PublicKey: tag[1],
|
||||
Relays: relays,
|
||||
}
|
||||
case "e":
|
||||
relays := make([]string, 0, 1)
|
||||
if len(tag) > 2 && tag[2] != "" {
|
||||
relays = append(relays, tag[2])
|
||||
}
|
||||
reference.Event = &nostr.EventPointer{
|
||||
ID: tag[1],
|
||||
Relays: relays,
|
||||
}
|
||||
case "a":
|
||||
if parts := strings.Split(tag[1], ":"); len(parts) == 3 {
|
||||
kind, _ := strconv.Atoi(parts[0])
|
||||
relays := make([]string, 0, 1)
|
||||
if len(tag) > 2 && tag[2] != "" {
|
||||
relays = append(relays, tag[2])
|
||||
}
|
||||
reference.Entity = &nostr.EntityPointer{
|
||||
Identifier: parts[2],
|
||||
PublicKey: parts[1],
|
||||
Kind: kind,
|
||||
Relays: relays,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
references = append(references, reference)
|
||||
}
|
||||
|
||||
return references
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
func TestParseReferences(t *testing.T) {
|
||||
evt := nostr.Event{
|
||||
Tags: nostr.Tags{
|
||||
{"p", "c9d556c6d3978d112d30616d0d20aaa81410e3653911dd67787b5aaf9b36ade8", "wss://nostr.com"},
|
||||
{"e", "a84c5de86efc2ec2cff7bad077c4171e09146b633b7ad117fffe088d9579ac33", "wss://other.com", "reply"},
|
||||
{"e", "31d7c2875b5fc8e6f9c8f9dc1f84de1b6b91d1947ea4c59225e55c325d330fa8", ""},
|
||||
},
|
||||
Content: "hello #[0], have you seen #[2]? it was made by nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg on nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4! broken #[3]",
|
||||
}
|
||||
|
||||
expected := []Reference{
|
||||
{
|
||||
Text: "#[0]",
|
||||
Start: 6,
|
||||
End: 10,
|
||||
Profile: &nostr.ProfilePointer{
|
||||
PublicKey: "c9d556c6d3978d112d30616d0d20aaa81410e3653911dd67787b5aaf9b36ade8",
|
||||
Relays: []string{"wss://nostr.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "#[2]",
|
||||
Start: 26,
|
||||
End: 30,
|
||||
Event: &nostr.EventPointer{
|
||||
ID: "31d7c2875b5fc8e6f9c8f9dc1f84de1b6b91d1947ea4c59225e55c325d330fa8",
|
||||
Relays: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "nostr:nprofile1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8yc5usxdg",
|
||||
Start: 47,
|
||||
End: 123,
|
||||
Profile: &nostr.ProfilePointer{
|
||||
PublicKey: "cc6b9fea033f59c3c39a0407c5f1bfee439b077508d918cfdc0d6fd431d39393",
|
||||
Relays: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Text: "nostr:nevent1qqsvc6ulagpn7kwrcwdqgp797xl7usumqa6s3kgcelwq6m75x8fe8ychxp5v4",
|
||||
Start: 127,
|
||||
End: 201,
|
||||
Event: &nostr.EventPointer{
|
||||
ID: "cc6b9fea033f59c3c39a0407c5f1bfee439b077508d918cfdc0d6fd431d39393",
|
||||
Relays: []string{},
|
||||
Author: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got := ParseReferences(&evt)
|
||||
|
||||
if len(got) != len(expected) {
|
||||
t.Errorf("got %d references, expected %d", len(got), len(expected))
|
||||
}
|
||||
|
||||
for i, g := range got {
|
||||
e := expected[i]
|
||||
if g.Text != e.Text {
|
||||
t.Errorf("%d: got text %s, expected %s", i, g.Text, e.Text)
|
||||
}
|
||||
|
||||
if g.Start != e.Start {
|
||||
t.Errorf("%d: got start %d, expected %d", i, g.Start, e.Start)
|
||||
}
|
||||
|
||||
if g.End != e.End {
|
||||
t.Errorf("%d: got end %d, expected %d", i, g.End, e.End)
|
||||
}
|
||||
|
||||
if (g.Entity == nil && e.Entity != nil) ||
|
||||
(g.Event == nil && e.Event != nil) ||
|
||||
(g.Profile == nil && e.Profile != nil) {
|
||||
t.Errorf("%d: got some unexpected nil", i)
|
||||
}
|
||||
|
||||
if g.Profile != nil && (g.Profile.PublicKey != e.Profile.PublicKey ||
|
||||
len(g.Profile.Relays) != len(e.Profile.Relays) ||
|
||||
(len(g.Profile.Relays) > 0 && g.Profile.Relays[0] != e.Profile.Relays[0])) {
|
||||
t.Errorf("%d: profile value is wrong", i)
|
||||
}
|
||||
|
||||
if g.Event != nil && (g.Event.ID != e.Event.ID ||
|
||||
g.Event.Author != e.Event.Author ||
|
||||
len(g.Event.Relays) != len(e.Event.Relays) ||
|
||||
(len(g.Event.Relays) > 0 && g.Event.Relays[0] != e.Event.Relays[0])) {
|
||||
fmt.Println(g.Event.ID, g.Event.Relays, len(g.Event.Relays), g.Event.Relays[0] == "")
|
||||
fmt.Println(e.Event.Relays, len(e.Event.Relays))
|
||||
t.Errorf("%d: event value is wrong", i)
|
||||
}
|
||||
|
||||
if g.Entity != nil && (g.Entity.PublicKey != e.Entity.PublicKey ||
|
||||
g.Entity.Identifier != e.Entity.Identifier ||
|
||||
g.Entity.Kind != e.Entity.Kind ||
|
||||
len(g.Entity.Relays) != len(g.Entity.Relays)) {
|
||||
t.Errorf("%d: entity value is wrong", i)
|
||||
}
|
||||
}
|
||||
}
|
112
sdk/relays.go
112
sdk/relays.go
@ -1,112 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
type Relay struct {
|
||||
URL string
|
||||
Inbox bool
|
||||
Outbox bool
|
||||
}
|
||||
|
||||
func FetchRelaysForPubkey(ctx context.Context, pool *nostr.SimplePool, pubkey string, relays ...string) []Relay {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
ch := pool.SubManyEose(ctx, relays, nostr.Filters{
|
||||
{
|
||||
Kinds: []int{
|
||||
nostr.KindRelayListMetadata,
|
||||
nostr.KindContactList,
|
||||
},
|
||||
Authors: []string{pubkey},
|
||||
Limit: 2,
|
||||
},
|
||||
})
|
||||
|
||||
result := make([]Relay, 0, 20)
|
||||
i := 0
|
||||
for ie := range ch {
|
||||
switch ie.Event.Kind {
|
||||
case nostr.KindRelayListMetadata:
|
||||
result = append(result, ParseRelaysFromKind10002(ie.Event)...)
|
||||
case nostr.KindContactList:
|
||||
result = append(result, ParseRelaysFromKind3(ie.Event)...)
|
||||
}
|
||||
|
||||
i++
|
||||
if i >= 2 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func ParseRelaysFromKind10002(evt *nostr.Event) []Relay {
|
||||
result := make([]Relay, 0, len(evt.Tags))
|
||||
for _, tag := range evt.Tags {
|
||||
if u := tag.Value(); u != "" && tag[0] == "r" {
|
||||
if !nostr.IsValidRelayURL(u) {
|
||||
continue
|
||||
}
|
||||
u := nostr.NormalizeURL(u)
|
||||
|
||||
relay := Relay{
|
||||
URL: u,
|
||||
}
|
||||
|
||||
if len(tag) == 2 {
|
||||
relay.Inbox = true
|
||||
relay.Outbox = true
|
||||
} else if tag[2] == "write" {
|
||||
relay.Outbox = true
|
||||
} else if tag[2] == "read" {
|
||||
relay.Inbox = true
|
||||
}
|
||||
|
||||
result = append(result, relay)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func ParseRelaysFromKind3(evt *nostr.Event) []Relay {
|
||||
type Item struct {
|
||||
Read bool `json:"read"`
|
||||
Write bool `json:"write"`
|
||||
}
|
||||
|
||||
items := make(map[string]Item, 20)
|
||||
json.Unmarshal([]byte(evt.Content), &items)
|
||||
|
||||
results := make([]Relay, len(items))
|
||||
i := 0
|
||||
for u, item := range items {
|
||||
if !nostr.IsValidRelayURL(u) {
|
||||
continue
|
||||
}
|
||||
u := nostr.NormalizeURL(u)
|
||||
|
||||
relay := Relay{
|
||||
URL: u,
|
||||
}
|
||||
|
||||
if item.Read {
|
||||
relay.Inbox = true
|
||||
}
|
||||
if item.Write {
|
||||
relay.Outbox = true
|
||||
}
|
||||
|
||||
results = append(results, relay)
|
||||
i++
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/sdk/cache"
|
||||
)
|
||||
|
||||
type System struct {
|
||||
RelaysCache cache.Cache32[[]Relay]
|
||||
FollowsCache cache.Cache32[[]Follow]
|
||||
MetadataCache cache.Cache32[ProfileMetadata]
|
||||
Pool *nostr.SimplePool
|
||||
RelayListRelays []string
|
||||
FollowListRelays []string
|
||||
MetadataRelays []string
|
||||
}
|
||||
|
||||
func (sys System) FetchRelays(ctx context.Context, pubkey string) []Relay {
|
||||
if v, ok := sys.RelaysCache.Get(pubkey); ok {
|
||||
return v
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
||||
defer cancel()
|
||||
res := FetchRelaysForPubkey(ctx, sys.Pool, pubkey, sys.RelayListRelays...)
|
||||
sys.RelaysCache.SetWithTTL(pubkey, res, time.Hour*6)
|
||||
return res
|
||||
}
|
||||
|
||||
func (sys System) FetchOutboxRelays(ctx context.Context, pubkey string) []string {
|
||||
relays := sys.FetchRelays(ctx, pubkey)
|
||||
result := make([]string, 0, len(relays))
|
||||
for _, relay := range relays {
|
||||
if relay.Outbox {
|
||||
result = append(result, relay.URL)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (sys System) FetchProfileMetadata(ctx context.Context, pubkey string) ProfileMetadata {
|
||||
if v, ok := sys.MetadataCache.Get(pubkey); ok {
|
||||
return v
|
||||
}
|
||||
|
||||
ctxRelays, cancel := context.WithTimeout(ctx, time.Second*2)
|
||||
relays := sys.FetchOutboxRelays(ctxRelays, pubkey)
|
||||
cancel()
|
||||
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Second*3)
|
||||
res := FetchProfileMetadata(ctx, sys.Pool, pubkey, append(relays, sys.MetadataRelays...)...)
|
||||
cancel()
|
||||
|
||||
sys.MetadataCache.SetWithTTL(pubkey, res, time.Hour*6)
|
||||
return res
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user