From 2e666843f1602d6f969ddc81e0df865f7b1c358e Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 27 Sep 2022 17:10:49 -0500 Subject: [PATCH] Move claimtrie-related service/handlers to jsonrpc_claimtrie.go. --- server/jsonrpc_claimtrie.go | 27 +++++++++++++++++++++++++++ server/jsonrpc_service.go | 24 +----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 server/jsonrpc_claimtrie.go diff --git a/server/jsonrpc_claimtrie.go b/server/jsonrpc_claimtrie.go new file mode 100644 index 0000000..a8ef42b --- /dev/null +++ b/server/jsonrpc_claimtrie.go @@ -0,0 +1,27 @@ +package server + +import ( + "github.com/lbryio/herald.go/db" + pb "github.com/lbryio/herald.go/protobuf/go" + log "github.com/sirupsen/logrus" +) + +type ClaimtrieService struct { + DB *db.ReadOnlyDBColumnFamily +} + +type ResolveData struct { + Data []string `json:"data"` +} + +type Result struct { + Data string `json:"data"` +} + +// Resolve is the json rpc endpoint for 'blockchain.claimtrie.resolve'. +func (t *ClaimtrieService) Resolve(args *ResolveData, result **pb.Outputs) error { + log.Println("Resolve") + res, err := InternalResolve(args.Data, t.DB) + *result = res + return err +} diff --git a/server/jsonrpc_service.go b/server/jsonrpc_service.go index c13fbcb..0f91843 100644 --- a/server/jsonrpc_service.go +++ b/server/jsonrpc_service.go @@ -8,31 +8,9 @@ import ( gorilla_mux "github.com/gorilla/mux" gorilla_rpc "github.com/gorilla/rpc" gorilla_json "github.com/gorilla/rpc/json" - "github.com/lbryio/herald.go/db" - pb "github.com/lbryio/herald.go/protobuf/go" log "github.com/sirupsen/logrus" ) -type ClaimtrieService struct { - DB *db.ReadOnlyDBColumnFamily -} - -type ResolveData struct { - Data []string `json:"data"` -} - -type Result struct { - Data string `json:"data"` -} - -// Resolve is the json rpc endpoint for 'blockchain.claimtrie.resolve'. -func (t *ClaimtrieService) Resolve(r *http.Request, args *ResolveData, result **pb.Outputs) error { - log.Println("Resolve") - res, err := InternalResolve(args.Data, t.DB) - *result = res - return err -} - type gorillaRpcCodec struct { gorilla_rpc.Codec } @@ -79,7 +57,7 @@ func (s *Server) StartJsonRPC() error { // Register "blockchain.claimtrie.*"" handlers. claimtrieSvc := &ClaimtrieService{s.DB} - err := s1.RegisterService(claimtrieSvc, "blockchain_claimtrie") + err := s1.RegisterTCPService(claimtrieSvc, "blockchain_claimtrie") if err != nil { log.Errorf("RegisterService: %v\n", err) }