WIP: Resolve json rpc #57
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.idea/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
.venv
|
||||
|
|
2
go.mod
|
@ -8,6 +8,8 @@ require (
|
|||
github.com/ReneKroon/ttlcache/v2 v2.8.1
|
||||
github.com/akamensky/argparse v1.2.2
|
||||
github.com/go-restruct/restruct v1.2.0-alpha
|
||||
github.com/gorilla/mux v1.7.3
|
||||
github.com/gorilla/rpc v1.2.0
|
||||
github.com/lbryio/lbry.go/v3 v3.0.1-beta
|
||||
github.com/linxGnu/grocksdb v1.6.42
|
||||
github.com/olivere/elastic/v7 v7.0.24
|
||||
|
|
8
go.sum
|
@ -235,8 +235,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
|
@ -252,7 +252,9 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
|
|||
github.com/gopherjs/gopherjs v0.0.0-20190915194858-d3ddacdb130f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
|
||||
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
|
@ -764,7 +766,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab h1:rfJ1bsoJQQIAoAxTxB7bme+vHrNkRw8CqfsYh9w54cw=
|
||||
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
@ -817,12 +818,11 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
|||
golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 h1:0c3L82FDQ5rt1bjTBlchS8t6RQ6299/+5bWMnRLh+uI=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
|
|
8
main.go
|
@ -39,9 +39,13 @@ func main() {
|
|||
defer func() {
|
||||
log.Println("Shutting down server...")
|
||||
|
||||
s.EsClient.Stop()
|
||||
if !s.Args.DisableEs {
|
||||
s.EsClient.Stop()
|
||||
}
|
||||
s.GrpcServer.GracefulStop()
|
||||
s.DB.Shutdown()
|
||||
if !s.Args.DisableResolve {
|
||||
s.DB.Shutdown()
|
||||
}
|
||||
|
||||
log.Println("Returning from main...")
|
||||
}()
|
||||
|
|
16
requirements.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
certifi==2022.6.15
|
||||
cffi==1.15.1
|
||||
charset-normalizer==2.1.0
|
||||
cryptography==37.0.4
|
||||
github3.py==3.2.0
|
||||
grpcio==1.47.0
|
||||
grpcio-tools==1.47.0
|
||||
idna==3.3
|
||||
protobuf==3.20.1
|
||||
pycparser==2.21
|
||||
PyJWT==2.4.0
|
||||
python-dateutil==2.8.2
|
||||
requests==2.28.1
|
||||
six==1.16.0
|
||||
uritemplate==4.1.1
|
||||
urllib3==1.26.11
|
||||
Yes, this is needed by the version.py, it was intentional. Yes, this is needed by the version.py, it was intentional.
|
|
@ -43,6 +43,7 @@ type Args struct {
|
|||
DisableResolve bool
|
||||
DisableBlockingAndFiltering bool
|
||||
DisableStartNotifier bool
|
||||
DisableStartJSONRPC bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -67,6 +68,7 @@ const (
|
|||
DefaultDisableResolve = false
|
||||
DefaultDisableBlockingAndFiltering = false
|
||||
DisableStartNotifier = false
|
||||
DisableStartJSONRPC = false
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -131,6 +133,7 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
|||
disableResolve := parser.Flag("", "disable-resolve", &argparse.Options{Required: false, Help: "Disable resolve endpoint (and rocksdb loading)", Default: DefaultDisableRockDBRefresh})
|
||||
disableBlockingAndFiltering := parser.Flag("", "disable-blocking-and-filtering", &argparse.Options{Required: false, Help: "Disable blocking and filtering of channels and streams", Default: DefaultDisableBlockingAndFiltering})
|
||||
disableStartNotifier := parser.Flag("", "disable-start-notifier", &argparse.Options{Required: false, Help: "Disable start notifier", Default: DisableStartNotifier})
|
||||
disableStartJSONRPC := parser.Flag("", "disable-start-jsonrpc", &argparse.Options{Required: false, Help: "Disable start jsonrpc endpoint", Default: DisableStartJSONRPC})
|
||||
|
||||
text := parser.String("", "text", &argparse.Options{Required: false, Help: "text query"})
|
||||
name := parser.String("", "name", &argparse.Options{Required: false, Help: "name"})
|
||||
|
@ -175,6 +178,7 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
|||
DisableResolve: *disableResolve,
|
||||
DisableBlockingAndFiltering: *disableBlockingAndFiltering,
|
||||
DisableStartNotifier: *disableStartNotifier,
|
||||
DisableStartJSONRPC: *disableStartJSONRPC,
|
||||
}
|
||||
|
||||
if esHost, ok := environment["ELASTIC_HOST"]; ok {
|
||||
|
|
49
server/jsonrpc_service.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
package server
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
import (
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"log"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"net/http"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"github.com/gorilla/mux"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"github.com/gorilla/rpc"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"github.com/gorilla/rpc/json"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
"github.com/lbryio/herald.go/db"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
pb "github.com/lbryio/herald.go/protobuf/go"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
)
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
type JSONServer struct {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
DB *db.ReadOnlyDBColumnFamily
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
}
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
type ResolveData struct {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
Data []string `json:"data"`
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
}
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
type Result struct {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
Data string `json:"data"`
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
}
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
//func (t *JSONServer) Resolve2(r *http.Request, args *ResolveData, result *Result) error {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
func (t *JSONServer) Resolve2(r *http.Request, args *ResolveData, result **pb.Outputs) error {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
log.Println("Resolve2")
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
res, err := InternalResolve(args.Data, t.DB)
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
*result = res
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
return err
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
}
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
func (s *Server) StartJsonRPC111() error {
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
server := new(JSONServer)
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
server.DB = s.DB
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
port := ":8080"
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
s1 := rpc.NewServer() // Create a new RPC server
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
s1.RegisterCodec(json.NewCodec(), "application/json") // Register the type of data requested as JSON
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
s1.RegisterService(server, "") // Register the service by creating a new JSON server
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
r := mux.NewRouter()
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
r.Handle("/rpc", s1)
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
log.Fatal(http.ListenAndServe(port, r))
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
return nil
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
||||
}
|
||||
JSON port number should be a new thing in args.go, defaulting to 50001. Then pass the args struct (or json parts of it) into StartJsonRPC111(). JSON port number should be a new thing in args.go, defaulting to 50001.
Then pass the args struct (or json parts of it) into StartJsonRPC111().
Yup, I just added that. It's already carried in through the Server struct. Yup, I just added that. It's already carried in through the Server struct.
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io/ioutil"
|
||||
|
@ -307,6 +308,14 @@ func MakeHubServer(ctx context.Context, args *Args) *Server {
|
|||
}
|
||||
}()
|
||||
}
|
||||
if !args.DisableStartJSONRPC {
|
||||
go func() {
|
||||
err := s.StartJsonRPC111()
|
||||
if err != nil {
|
||||
log.Println("JSONRPC Server failed!", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
// Load peers from disk and subscribe to one if there are any
|
||||
if !args.DisableLoadPeers {
|
||||
go func() {
|
||||
|
@ -447,13 +456,49 @@ func (s *Server) HeightHashSubscribe() error {
|
|||
}
|
||||
|
||||
func (s *Server) Resolve(ctx context.Context, args *pb.StringArray) (*pb.Outputs, error) {
|
||||
// metrics.RequestsCount.With(prometheus.Labels{"method": "resolve"}).Inc()
|
||||
|
||||
// allTxos := make([]*pb.Output, 0)
|
||||
// allExtraTxos := make([]*pb.Output, 0)
|
||||
|
||||
// for _, url := range args.Value {
|
||||
// res := s.DB.Resolve(url)
|
||||
// txos, extraTxos, err := res.ToOutputs()
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// // TODO: there may be a more efficient way to do this.
|
||||
// allTxos = append(allTxos, txos...)
|
||||
// allExtraTxos = append(allExtraTxos, extraTxos...)
|
||||
// }
|
||||
|
||||
// res := &pb.Outputs{
|
||||
// Txos: allTxos,
|
||||
// ExtraTxos: allExtraTxos,
|
||||
// Total: uint32(len(allTxos) + len(allExtraTxos)),
|
||||
// Offset: 0, //TODO
|
||||
// Blocked: nil, //TODO
|
||||
// BlockedTotal: 0, //TODO
|
||||
// }
|
||||
|
||||
// logrus.Warn(res)
|
||||
|
||||
// return res, nil
|
||||
return InternalResolve(args.Value, s.DB)
|
||||
}
|
||||
|
||||
func InternalResolve(urls []string, DB *db.ReadOnlyDBColumnFamily) (*pb.Outputs, error) {
|
||||
if DB == nil {
|
||||
return nil, errors.New("db is nil")
|
||||
// return nil, nil
|
||||
}
|
||||
metrics.RequestsCount.With(prometheus.Labels{"method": "resolve"}).Inc()
|
||||
|
||||
allTxos := make([]*pb.Output, 0)
|
||||
allExtraTxos := make([]*pb.Output, 0)
|
||||
|
||||
for _, url := range args.Value {
|
||||
res := s.DB.Resolve(url)
|
||||
for _, url := range urls {
|
||||
res := DB.Resolve(url)
|
||||
txos, extraTxos, err := res.ToOutputs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
10
test_rpc.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
#!/bin/bash
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
curl --request POST 'localhost:8686/' \
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
--http1.1 \
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
--header 'Content-Type: application/json' \
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
--data-raw '{
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
"jsonrpc":"2.0",
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
"method":"resolve",
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
"params":{"data": "asdf"},
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
"id":1
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
||||
}'
|
||||
Where does this port number come from? I would expect to see 8080 (or 50001) Also does this need "/rpc" to match line 45 of jsonrpc_service.go? I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s). Where does this port number come from? I would expect to see 8080 (or 50001)
Also does this need "/rpc" to match line 45 of jsonrpc_service.go?
I haven't been able to determine whether (Python) herald uses "/rpc" or any other path(s).
This is an old script added in by mistake, I'll move and change it. This is an old script added in by mistake, I'll move and change it.
|
Is this needed by scripts/version.py? Did it get created inadvertently?