From 23f6ab31ba5777a64baacb2bbd70a5cd9626d144 Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Thu, 6 Jun 2024 14:34:51 +0200 Subject: [PATCH 1/5] Add old-faithful-grpc server --- Makefile | 14 +- cmd-rpc.go | 27 +- go.mod | 16 +- go.sum | 43 +- grpc-server.go | 430 +++++++++++ multiepoch.go | 2 + .../old-faithful-grpc/old-faithful.pb.go | 678 ++++++++++++++++++ .../old-faithful-grpc/old-faithful_grpc.pb.go | 186 +++++ old-faithful-proto/proto/old-faithful.proto | 7 +- storage.go | 23 + txstatus/.gitignore | 1 + 11 files changed, 1395 insertions(+), 32 deletions(-) create mode 100644 grpc-server.go create mode 100644 old-faithful-proto/old-faithful-grpc/old-faithful.pb.go create mode 100644 old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go diff --git a/Makefile b/Makefile index e27e417e..ec229f44 100644 --- a/Makefile +++ b/Makefile @@ -57,10 +57,10 @@ install-protoc: @mkdir -p $$(pwd)/third_party/protoc @echo "Getting the latest release of protoc from github.com/protocolbuffers/protobuf..." @cd $$(pwd)/third_party/protoc && \ - wget https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-linux-x86_64.zip + wget https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-x86_64.zip @echo "Unzipping protoc..." @cd $$(pwd)/third_party/protoc && \ - unzip protoc-23.1-linux-x86_64.zip + unzip protoc-27.1-linux-x86_64.zip @echo "Installing protoc-gen-go..." @go install google.golang.org/protobuf/cmd/protoc-gen-go@latest @go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest @@ -76,3 +76,13 @@ gen-proto: install-protoc --go_out=paths=source_relative:$$(pwd)/third_party/solana_proto/transaction_by_addr \ -I=$$(pwd)/third_party/solana_proto/transaction_by_addr/ \ $$(pwd)/third_party/solana_proto/transaction_by_addr/transaction_by_addr.proto +gen-old-faithful-proto: install-protoc + @mkdir -p $$(pwd)/old-faithful-proto/old-faithful-grpc + @echo "Generating golang protobuf for old-faithful..." + # the proto file is in old-faithful-proto/proto ; generate go code in old-faithful-proto/faithful-grpc + $$(pwd)/third_party/protoc/bin/protoc \ + --experimental_allow_proto3_optional \ + --go_out=paths=source_relative:$$(pwd)/old-faithful-proto/old-faithful-grpc \ + --go-grpc_out=paths=source_relative:$$(pwd)/old-faithful-proto/old-faithful-grpc \ + -I=$$(pwd)/old-faithful-proto/proto/ \ + $$(pwd)/old-faithful-proto/proto/old-faithful.proto diff --git a/cmd-rpc.go b/cmd-rpc.go index 23e8d293..7f0ee63b 100644 --- a/cmd-rpc.go +++ b/cmd-rpc.go @@ -32,6 +32,7 @@ func newCmd_rpc() *cli.Command { var epochSearchConcurrency int var epochLoadConcurrency int var maxCacheSizeMB int + var grpcListenOn string return &cli.Command{ Name: "rpc", Usage: "Start a Solana JSON RPC server.", @@ -47,6 +48,12 @@ func newCmd_rpc() *cli.Command { Value: ":8899", Destination: &listenOn, }, + &cli.StringFlag{ + Name: "grpc-listen", + Usage: "Listen address for gRPC", + Value: ":8898", + Destination: &grpcListenOn, + }, &cli.BoolFlag{ Name: "gsfa-only-signatures", Usage: "gSFA: only return signatures", @@ -313,8 +320,26 @@ func newCmd_rpc() *cli.Command { ProxyConfig: proxyConfig, } } + allListeners := new(errgroup.Group) + + if grpcListenOn != "" { + allListeners.Go(func() error { + err := multi.ListenAndServeGRPC(c.Context, grpcListenOn) + if err != nil { + return fmt.Errorf("failed to start gRPC server: %w", err) + } + return nil + }) + } + allListeners.Go(func() error { + err := multi.ListenAndServe(c.Context, listenOn, listenerConfig) + if err != nil { + return fmt.Errorf("failed to start JSON RPC server: %w", err) + } + return nil + }) - return multi.ListenAndServe(c.Context, listenOn, listenerConfig) + return allListeners.Wait() }, } } diff --git a/go.mod b/go.mod index e35bd9b4..aa684c21 100644 --- a/go.mod +++ b/go.mod @@ -46,9 +46,9 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sync v0.4.0 - google.golang.org/protobuf v1.31.0 + golang.org/x/net v0.22.0 // indirect + golang.org/x/sync v0.6.0 + google.golang.org/protobuf v1.33.0 k8s.io/klog/v2 v2.90.1 ) @@ -78,6 +78,7 @@ require ( github.com/valyala/fasthttp v1.47.0 github.com/ybbus/jsonrpc/v3 v3.1.5 golang.org/x/exp v0.0.0-20231006140011-7918f672742d + google.golang.org/grpc v1.64.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/klog v1.0.0 @@ -217,13 +218,14 @@ require ( go.uber.org/mock v0.3.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.13.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect golang.org/x/tools v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index 94f6a08f..8d6ad29e 100644 --- a/go.sum +++ b/go.sum @@ -275,9 +275,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -288,9 +287,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/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.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= 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= @@ -981,8 +979,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1053,8 +1051,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1074,8 +1072,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1127,13 +1125,13 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1141,8 +1139,8 @@ 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= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1247,6 +1245,8 @@ google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -1262,6 +1262,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1271,9 +1273,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/grpc-server.go b/grpc-server.go new file mode 100644 index 00000000..36b6eb86 --- /dev/null +++ b/grpc-server.go @@ -0,0 +1,430 @@ +package main + +import ( + "bufio" + "bytes" + "context" + "errors" + "fmt" + "io" + "net" + "runtime" + "sort" + "sync" + "time" + + "github.com/gagliardetto/solana-go" + "github.com/ipfs/go-cid" + "github.com/ipld/go-car/util" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/rpcpool/yellowstone-faithful/compactindexsized" + "github.com/rpcpool/yellowstone-faithful/ipld/ipldbindcode" + old_faithful_grpc "github.com/rpcpool/yellowstone-faithful/old-faithful-proto/old-faithful-grpc" + "golang.org/x/sync/errgroup" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + _ "google.golang.org/grpc/encoding/gzip" // Install the gzip compressor + "google.golang.org/grpc/status" + "k8s.io/klog/v2" +) + +// ListeAndServe starts listening on the configured address and serves the RPC API. +func (me *MultiEpoch) ListenAndServeGRPC(ctx context.Context, listenOn string) error { + lis, err := net.Listen("tcp", listenOn) + if err != nil { + return fmt.Errorf("failed to create listener for gRPC server: %w", err) + } + + grpcServer := grpc.NewServer() + old_faithful_grpc.RegisterOldFaithfulServer(grpcServer, me) + + if err := grpcServer.Serve(lis); err != nil { + return fmt.Errorf("failed to serve gRPC server: %w", err) + } + return nil +} + +func (me *MultiEpoch) GetVersion(context.Context, *old_faithful_grpc.VersionRequest) (*old_faithful_grpc.VersionResponse, error) { + // faithfulVersion["version"] = GitTag + // faithfulVersion["commit"] = GitCommit + // faithfulVersion["epochs"] = me.GetEpochNumbers() + resp := &old_faithful_grpc.VersionResponse{ + Version: func() string { + if GitTag == "" { + return GitCommit + } + return GitTag + }(), + Commit: GitCommit, + Epochs: me.GetEpochNumbers(), + } + return resp, nil +} + +func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc.BlockRequest) (*old_faithful_grpc.BlockResponse, error) { + // find the epoch that contains the requested slot + slot := params.Slot + epochNumber := CalcEpochForSlot(slot) + epochHandler, err := multi.GetEpoch(epochNumber) + if err != nil { + return nil, status.Errorf(codes.NotFound, "Epoch %d is not available", epochNumber) + } + + block, _, err := epochHandler.GetBlock(WithSubrapghPrefetch(ctx, true), slot) + if err != nil { + if errors.Is(err, compactindexsized.ErrNotFound) { + return nil, status.Errorf(codes.NotFound, "Slot %d was skipped, or missing in long-term storage", slot) + } else { + return nil, status.Errorf(codes.Internal, "Failed to get block: %v", err) + } + } + + tim := newTimer(getRequestIDFromContext(ctx)) + tim.time("GetBlock") + { + prefetcherFromCar := func() error { + parentIsInPreviousEpoch := CalcEpochForSlot(uint64(block.Meta.Parent_slot)) != CalcEpochForSlot(slot) + if slot == 0 { + parentIsInPreviousEpoch = true + } + if slot > 1 && block.Meta.Parent_slot == 0 { + parentIsInPreviousEpoch = true + } + + var blockCid, parentBlockCid cid.Cid + wg := new(errgroup.Group) + wg.Go(func() (err error) { + blockCid, err = epochHandler.FindCidFromSlot(ctx, slot) + if err != nil { + return err + } + return nil + }) + wg.Go(func() (err error) { + if parentIsInPreviousEpoch { + return nil + } + parentBlockCid, err = epochHandler.FindCidFromSlot(ctx, uint64(block.Meta.Parent_slot)) + if err != nil { + return err + } + return nil + }) + err = wg.Wait() + if err != nil { + return err + } + if slot == 0 { + klog.V(4).Infof("car start to slot(0)::%s", blockCid) + } else { + klog.V(4).Infof( + "slot(%d)::%s to slot(%d)::%s", + uint64(block.Meta.Parent_slot), + parentBlockCid, + slot, + blockCid, + ) + } + { + var blockOffset, parentOffset uint64 + wg := new(errgroup.Group) + wg.Go(func() (err error) { + offsetAndSize, err := epochHandler.FindOffsetAndSizeFromCid(ctx, blockCid) + if err != nil { + return err + } + blockOffset = offsetAndSize.Offset + return nil + }) + wg.Go(func() (err error) { + if parentIsInPreviousEpoch { + // get car file header size + parentOffset = epochHandler.carHeaderSize + return nil + } + offsetAndSize, err := epochHandler.FindOffsetAndSizeFromCid(ctx, parentBlockCid) + if err != nil { + return err + } + parentOffset = offsetAndSize.Offset + return nil + }) + err = wg.Wait() + if err != nil { + return err + } + + length := blockOffset - parentOffset + MiB := uint64(1024 * 1024) + maxPrefetchSize := MiB * 10 // let's cap prefetching size + if length > maxPrefetchSize { + length = maxPrefetchSize + } + + start := parentOffset + + klog.V(4).Infof("prefetching CAR: start=%d length=%d (parent_offset=%d)", start, length, parentOffset) + carSection, err := epochHandler.ReadAtFromCar(ctx, start, length) + if err != nil { + return err + } + dr := bytes.NewReader(carSection) + br := bufio.NewReader(dr) + + gotCid, data, err := util.ReadNode(br) + if err != nil { + return fmt.Errorf("failed to read first node: %w", err) + } + if !parentIsInPreviousEpoch && !gotCid.Equals(parentBlockCid) { + return fmt.Errorf("CID mismatch: expected %s, got %s", parentBlockCid, gotCid) + } + epochHandler.GetCache().PutRawCarObject(gotCid, data) + + for { + gotCid, data, err = util.ReadNode(br) + if err != nil { + if errors.Is(err, io.EOF) { + break + } + return fmt.Errorf("failed to read node: %w", err) + } + if gotCid.Equals(blockCid) { + break + } + epochHandler.GetCache().PutRawCarObject(gotCid, data) + } + } + return nil + } + if epochHandler.lassieFetcher == nil { + err := prefetcherFromCar() + if err != nil { + klog.Errorf("failed to prefetch from car: %v", err) + } + } + } + blocktime := uint64(block.Meta.Blocktime) + + allTransactionNodes := make([][]*ipldbindcode.Transaction, len(block.Entries)) + mu := &sync.Mutex{} + var lastEntryHash solana.Hash + { + wg := new(errgroup.Group) + wg.SetLimit(runtime.NumCPU() * 2) + // get entries from the block + for entryIndex, entry := range block.Entries { + entryIndex := entryIndex + entryCid := entry.(cidlink.Link).Cid + wg.Go(func() error { + // get the entry by CID + entryNode, err := epochHandler.GetEntryByCid(ctx, entryCid) + if err != nil { + klog.Errorf("failed to decode Entry: %v", err) + return err + } + + if entryIndex == len(block.Entries)-1 { + lastEntryHash = solana.HashFromBytes(entryNode.Hash) + } + + twg := new(errgroup.Group) + twg.SetLimit(runtime.NumCPU()) + // get the transactions from the entry + allTransactionNodes[entryIndex] = make([]*ipldbindcode.Transaction, len(entryNode.Transactions)) + for txI := range entryNode.Transactions { + txI := txI + tx := entryNode.Transactions[txI] + twg.Go(func() error { + // get the transaction by CID + tcid := tx.(cidlink.Link).Cid + txNode, err := epochHandler.GetTransactionByCid(ctx, tcid) + if err != nil { + klog.Errorf("failed to decode Transaction %s: %v", tcid, err) + return nil + } + mu.Lock() + allTransactionNodes[entryIndex][txI] = txNode + mu.Unlock() + return nil + }) + } + return twg.Wait() + }) + } + err = wg.Wait() + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get entries: %v", err) + } + } + tim.time("get entries") + + resp := &old_faithful_grpc.BlockResponse{ + Slot: uint64(block.Slot), + } + + var allTransactions []*old_faithful_grpc.Transaction + hasRewards := !block.Rewards.(cidlink.Link).Cid.Equals(DummyCID) + if hasRewards { + rewardsNode, err := epochHandler.GetRewardsByCid(ctx, block.Rewards.(cidlink.Link).Cid) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get Rewards: %v", err) + } + rewardsBuf, err := loadDataFromDataFrames(&rewardsNode.Data, epochHandler.GetDataFrameByCid) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to load Rewards dataFrames: %v", err) + } + + uncompressedRawRewards, err := decompressZstd(rewardsBuf) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to decompress Rewards: %v", err) + } + resp.Rewards = uncompressedRawRewards + } + tim.time("get rewards") + { + for _, transactionNode := range mergeTxNodeSlices(allTransactionNodes) { + txResp := new(old_faithful_grpc.Transaction) + + // response.Slot = uint64(transactionNode.Slot) + // if blocktime != 0 { + // response.Blocktime = &blocktime + // } + + { + pos, ok := transactionNode.GetPositionIndex() + if ok { + txResp.Position = uint64(pos) + } + txResp.Transaction, txResp.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get transaction: %v", err) + } + } + + allTransactions = append(allTransactions, txResp) + } + } + + sort.Slice(allTransactions, func(i, j int) bool { + return allTransactions[i].Position < allTransactions[j].Position + }) + tim.time("get transactions") + resp.Transactions = allTransactions + if blocktime != 0 { + resp.BlockTime = int64(blocktime) + } + resp.Blockhash = lastEntryHash[:] + resp.ParentSlot = uint64(block.Meta.Parent_slot) + + if slot == 0 { + genesis := epochHandler.GetGenesis() + if genesis != nil { + blockZeroBlocktime := uint64(genesis.Config.CreationTime.Unix()) + resp.BlockTime = int64(blockZeroBlocktime) + } + resp.ParentSlot = uint64(0) + + zeroBlockHeight := uint64(0) + resp.BlockHeight = zeroBlockHeight + + blockZeroBlockHash := lastEntryHash + resp.PreviousBlockhash = blockZeroBlockHash[:] // NOTE: this is what solana RPC does. Should it be nil instead? Or should it be the genesis hash? + } + + { + blockHeight, ok := block.GetBlockHeight() + if ok { + resp.BlockHeight = blockHeight + } + } + { + // get parent slot + parentSlot := uint64(block.Meta.Parent_slot) + if (parentSlot != 0 || slot == 1) && CalcEpochForSlot(parentSlot) == epochNumber { + // NOTE: if the parent is in the same epoch, we can get it from the same epoch handler as the block; + // otherwise, we need to get it from the previous epoch (TODO: implement this) + parentBlock, _, err := epochHandler.GetBlock(WithSubrapghPrefetch(ctx, false), parentSlot) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get parent block: %v", err) + } + + if len(parentBlock.Entries) > 0 { + lastEntryCidOfParent := parentBlock.Entries[len(parentBlock.Entries)-1] + parentEntryNode, err := epochHandler.GetEntryByCid(ctx, lastEntryCidOfParent.(cidlink.Link).Cid) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get parent entry: %v", err) + } + parentEntryHash := solana.HashFromBytes(parentEntryNode.Hash) + resp.PreviousBlockhash = parentEntryHash[:] + } + } else { + if slot != 0 { + klog.V(4).Infof("parent slot is in a different epoch, not implemented yet (can't get previousBlockhash)") + } + } + } + tim.time("get parent block") + + return resp, nil +} + +func (multi *MultiEpoch) GetTransaction(ctx context.Context, params *old_faithful_grpc.TransactionRequest) (*old_faithful_grpc.TransactionResponse, error) { + if multi.CountEpochs() == 0 { + return nil, status.Errorf(codes.Internal, "no epochs available") + } + + sig := solana.SignatureFromBytes(params.Signature) + + startedEpochLookupAt := time.Now() + epochNumber, err := multi.findEpochNumberFromSignature(ctx, sig) + if err != nil { + if errors.Is(err, ErrNotFound) { + // solana just returns null here in case of transaction not found: {"jsonrpc":"2.0","result":null,"id":1} + return nil, status.Errorf(codes.NotFound, "Transaction not found") + } + return nil, status.Errorf(codes.Internal, "Failed to get epoch for signature %s: %v", sig, err) + } + klog.V(4).Infof("Found signature %s in epoch %d in %s", sig, epochNumber, time.Since(startedEpochLookupAt)) + + epochHandler, err := multi.GetEpoch(uint64(epochNumber)) + if err != nil { + return nil, status.Errorf(codes.NotFound, "Epoch %d is not available from this RPC", epochNumber) + } + + transactionNode, _, err := epochHandler.GetTransaction(WithSubrapghPrefetch(ctx, true), sig) + if err != nil { + if errors.Is(err, compactindexsized.ErrNotFound) { + // NOTE: solana just returns null here in case of transaction not found: {"jsonrpc":"2.0","result":null,"id":1} + return nil, status.Errorf(codes.NotFound, "Transaction not found") + } + return nil, status.Errorf(codes.Internal, "Failed to get transaction: %v", err) + } + + response := &old_faithful_grpc.TransactionResponse{ + Transaction: &old_faithful_grpc.Transaction{}, + } + response.Slot = uint64(transactionNode.Slot) + { + block, _, err := epochHandler.GetBlock(ctx, uint64(transactionNode.Slot)) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get block: %v", err) + } + blocktime := uint64(block.Meta.Blocktime) + if blocktime != 0 { + response.BlockTime = int64(blocktime) + } + } + + { + pos, ok := transactionNode.GetPositionIndex() + if ok { + response.Position = uint64(pos) + } + response.Transaction.Transaction, response.Transaction.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get transaction: %v", err) + } + } + + return response, nil +} diff --git a/multiepoch.go b/multiepoch.go index a5d6c56a..3f52040b 100644 --- a/multiepoch.go +++ b/multiepoch.go @@ -15,6 +15,7 @@ import ( "github.com/libp2p/go-reuseport" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rpcpool/yellowstone-faithful/ipld/ipldbindcode" + old_faithful_grpc "github.com/rpcpool/yellowstone-faithful/old-faithful-proto/old-faithful-grpc" "github.com/sourcegraph/jsonrpc2" "github.com/valyala/fasthttp" "github.com/valyala/fasthttp/fasthttpadaptor" @@ -30,6 +31,7 @@ type MultiEpoch struct { mu sync.RWMutex options *Options epochs map[uint64]*Epoch + old_faithful_grpc.UnimplementedOldFaithfulServer } func NewMultiEpoch(options *Options) *MultiEpoch { diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go new file mode 100644 index 00000000..1e6379d0 --- /dev/null +++ b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go @@ -0,0 +1,678 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.1 +// protoc v5.27.1 +// source: old-faithful.proto + +package old_faithful_grpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type VersionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *VersionRequest) Reset() { + *x = VersionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VersionRequest) ProtoMessage() {} + +func (x *VersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VersionRequest.ProtoReflect.Descriptor instead. +func (*VersionRequest) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{0} +} + +type VersionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Commit string `protobuf:"bytes,2,opt,name=commit,proto3" json:"commit,omitempty"` + Epochs []uint64 `protobuf:"varint,3,rep,packed,name=epochs,proto3" json:"epochs,omitempty"` +} + +func (x *VersionResponse) Reset() { + *x = VersionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VersionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VersionResponse) ProtoMessage() {} + +func (x *VersionResponse) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VersionResponse.ProtoReflect.Descriptor instead. +func (*VersionResponse) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{1} +} + +func (x *VersionResponse) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *VersionResponse) GetCommit() string { + if x != nil { + return x.Commit + } + return "" +} + +func (x *VersionResponse) GetEpochs() []uint64 { + if x != nil { + return x.Epochs + } + return nil +} + +type BlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Slot uint64 `protobuf:"varint,1,opt,name=slot,proto3" json:"slot,omitempty"` +} + +func (x *BlockRequest) Reset() { + *x = BlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockRequest) ProtoMessage() {} + +func (x *BlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockRequest.ProtoReflect.Descriptor instead. +func (*BlockRequest) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{2} +} + +func (x *BlockRequest) GetSlot() uint64 { + if x != nil { + return x.Slot + } + return 0 +} + +type BlockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PreviousBlockhash []byte `protobuf:"bytes,1,opt,name=previous_blockhash,json=previousBlockhash,proto3" json:"previous_blockhash,omitempty"` + Blockhash []byte `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` + ParentSlot uint64 `protobuf:"varint,3,opt,name=parent_slot,json=parentSlot,proto3" json:"parent_slot,omitempty"` + Slot uint64 `protobuf:"varint,4,opt,name=slot,proto3" json:"slot,omitempty"` + BlockTime int64 `protobuf:"varint,5,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` + BlockHeight uint64 `protobuf:"varint,6,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + Transactions []*Transaction `protobuf:"bytes,7,rep,name=transactions,proto3" json:"transactions,omitempty"` + Rewards []byte `protobuf:"bytes,8,opt,name=rewards,proto3" json:"rewards,omitempty"` +} + +func (x *BlockResponse) Reset() { + *x = BlockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BlockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BlockResponse) ProtoMessage() {} + +func (x *BlockResponse) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BlockResponse.ProtoReflect.Descriptor instead. +func (*BlockResponse) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{3} +} + +func (x *BlockResponse) GetPreviousBlockhash() []byte { + if x != nil { + return x.PreviousBlockhash + } + return nil +} + +func (x *BlockResponse) GetBlockhash() []byte { + if x != nil { + return x.Blockhash + } + return nil +} + +func (x *BlockResponse) GetParentSlot() uint64 { + if x != nil { + return x.ParentSlot + } + return 0 +} + +func (x *BlockResponse) GetSlot() uint64 { + if x != nil { + return x.Slot + } + return 0 +} + +func (x *BlockResponse) GetBlockTime() int64 { + if x != nil { + return x.BlockTime + } + return 0 +} + +func (x *BlockResponse) GetBlockHeight() uint64 { + if x != nil { + return x.BlockHeight + } + return 0 +} + +func (x *BlockResponse) GetTransactions() []*Transaction { + if x != nil { + return x.Transactions + } + return nil +} + +func (x *BlockResponse) GetRewards() []byte { + if x != nil { + return x.Rewards + } + return nil +} + +type TransactionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (x *TransactionRequest) Reset() { + *x = TransactionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransactionRequest) ProtoMessage() {} + +func (x *TransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TransactionRequest.ProtoReflect.Descriptor instead. +func (*TransactionRequest) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{4} +} + +func (x *TransactionRequest) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} + +type TransactionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Transaction *Transaction `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` + Slot uint64 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"` + BlockTime int64 `protobuf:"varint,3,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` + Position uint64 `protobuf:"varint,4,opt,name=position,proto3" json:"position,omitempty"` +} + +func (x *TransactionResponse) Reset() { + *x = TransactionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TransactionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TransactionResponse) ProtoMessage() {} + +func (x *TransactionResponse) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TransactionResponse.ProtoReflect.Descriptor instead. +func (*TransactionResponse) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{5} +} + +func (x *TransactionResponse) GetTransaction() *Transaction { + if x != nil { + return x.Transaction + } + return nil +} + +func (x *TransactionResponse) GetSlot() uint64 { + if x != nil { + return x.Slot + } + return 0 +} + +func (x *TransactionResponse) GetBlockTime() int64 { + if x != nil { + return x.BlockTime + } + return 0 +} + +func (x *TransactionResponse) GetPosition() uint64 { + if x != nil { + return x.Position + } + return 0 +} + +type Transaction struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` + Meta []byte `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"` // bincode or protobuf + Position uint64 `protobuf:"varint,4,opt,name=position,proto3" json:"position,omitempty"` +} + +func (x *Transaction) Reset() { + *x = Transaction{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Transaction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Transaction) ProtoMessage() {} + +func (x *Transaction) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Transaction.ProtoReflect.Descriptor instead. +func (*Transaction) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{6} +} + +func (x *Transaction) GetTransaction() []byte { + if x != nil { + return x.Transaction + } + return nil +} + +func (x *Transaction) GetMeta() []byte { + if x != nil { + return x.Meta + } + return nil +} + +func (x *Transaction) GetPosition() uint64 { + if x != nil { + return x.Position + } + return 0 +} + +var File_old_faithful_proto protoreflect.FileDescriptor + +var file_old_faithful_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x22, 0x10, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x5b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x70, 0x6f, 0x63, + 0x68, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x73, + 0x22, 0x22, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, + 0x73, 0x6c, 0x6f, 0x74, 0x22, 0xab, 0x02, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, + 0x75, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x11, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, 0x61, + 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x68, + 0x61, 0x73, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x6c, + 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x53, 0x6c, 0x6f, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x3c, 0x0a, 0x0c, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x77, 0x61, + 0x72, 0x64, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x22, 0x32, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xa0, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, + 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, + 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x5f, 0x0a, 0x0b, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, + 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xee, 0x01, 0x0a, 0x0b, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, 0x47, 0x65, + 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, + 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, + 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, + 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, + 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, 0x4c, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, 0x6f, 0x6f, + 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, 0x66, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, + 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_old_faithful_proto_rawDescOnce sync.Once + file_old_faithful_proto_rawDescData = file_old_faithful_proto_rawDesc +) + +func file_old_faithful_proto_rawDescGZIP() []byte { + file_old_faithful_proto_rawDescOnce.Do(func() { + file_old_faithful_proto_rawDescData = protoimpl.X.CompressGZIP(file_old_faithful_proto_rawDescData) + }) + return file_old_faithful_proto_rawDescData +} + +var file_old_faithful_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_old_faithful_proto_goTypes = []interface{}{ + (*VersionRequest)(nil), // 0: OldFaithful.VersionRequest + (*VersionResponse)(nil), // 1: OldFaithful.VersionResponse + (*BlockRequest)(nil), // 2: OldFaithful.BlockRequest + (*BlockResponse)(nil), // 3: OldFaithful.BlockResponse + (*TransactionRequest)(nil), // 4: OldFaithful.TransactionRequest + (*TransactionResponse)(nil), // 5: OldFaithful.TransactionResponse + (*Transaction)(nil), // 6: OldFaithful.Transaction +} +var file_old_faithful_proto_depIdxs = []int32{ + 6, // 0: OldFaithful.BlockResponse.transactions:type_name -> OldFaithful.Transaction + 6, // 1: OldFaithful.TransactionResponse.transaction:type_name -> OldFaithful.Transaction + 0, // 2: OldFaithful.OldFaithful.GetVersion:input_type -> OldFaithful.VersionRequest + 2, // 3: OldFaithful.OldFaithful.GetBlock:input_type -> OldFaithful.BlockRequest + 4, // 4: OldFaithful.OldFaithful.GetTransaction:input_type -> OldFaithful.TransactionRequest + 1, // 5: OldFaithful.OldFaithful.GetVersion:output_type -> OldFaithful.VersionResponse + 3, // 6: OldFaithful.OldFaithful.GetBlock:output_type -> OldFaithful.BlockResponse + 5, // 7: OldFaithful.OldFaithful.GetTransaction:output_type -> OldFaithful.TransactionResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_old_faithful_proto_init() } +func file_old_faithful_proto_init() { + if File_old_faithful_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_old_faithful_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VersionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BlockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TransactionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TransactionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Transaction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_old_faithful_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_old_faithful_proto_goTypes, + DependencyIndexes: file_old_faithful_proto_depIdxs, + MessageInfos: file_old_faithful_proto_msgTypes, + }.Build() + File_old_faithful_proto = out.File + file_old_faithful_proto_rawDesc = nil + file_old_faithful_proto_goTypes = nil + file_old_faithful_proto_depIdxs = nil +} diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go new file mode 100644 index 00000000..40e16525 --- /dev/null +++ b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go @@ -0,0 +1,186 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.4.0 +// - protoc v5.27.1 +// source: old-faithful.proto + +package old_faithful_grpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 + +const ( + OldFaithful_GetVersion_FullMethodName = "/OldFaithful.OldFaithful/GetVersion" + OldFaithful_GetBlock_FullMethodName = "/OldFaithful.OldFaithful/GetBlock" + OldFaithful_GetTransaction_FullMethodName = "/OldFaithful.OldFaithful/GetTransaction" +) + +// OldFaithfulClient is the client API for OldFaithful service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type OldFaithfulClient interface { + GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) + GetBlock(ctx context.Context, in *BlockRequest, opts ...grpc.CallOption) (*BlockResponse, error) + GetTransaction(ctx context.Context, in *TransactionRequest, opts ...grpc.CallOption) (*TransactionResponse, error) +} + +type oldFaithfulClient struct { + cc grpc.ClientConnInterface +} + +func NewOldFaithfulClient(cc grpc.ClientConnInterface) OldFaithfulClient { + return &oldFaithfulClient{cc} +} + +func (c *oldFaithfulClient) GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(VersionResponse) + err := c.cc.Invoke(ctx, OldFaithful_GetVersion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *oldFaithfulClient) GetBlock(ctx context.Context, in *BlockRequest, opts ...grpc.CallOption) (*BlockResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BlockResponse) + err := c.cc.Invoke(ctx, OldFaithful_GetBlock_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *oldFaithfulClient) GetTransaction(ctx context.Context, in *TransactionRequest, opts ...grpc.CallOption) (*TransactionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TransactionResponse) + err := c.cc.Invoke(ctx, OldFaithful_GetTransaction_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// OldFaithfulServer is the server API for OldFaithful service. +// All implementations must embed UnimplementedOldFaithfulServer +// for forward compatibility +type OldFaithfulServer interface { + GetVersion(context.Context, *VersionRequest) (*VersionResponse, error) + GetBlock(context.Context, *BlockRequest) (*BlockResponse, error) + GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) + mustEmbedUnimplementedOldFaithfulServer() +} + +// UnimplementedOldFaithfulServer must be embedded to have forward compatible implementations. +type UnimplementedOldFaithfulServer struct { +} + +func (UnimplementedOldFaithfulServer) GetVersion(context.Context, *VersionRequest) (*VersionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented") +} +func (UnimplementedOldFaithfulServer) GetBlock(context.Context, *BlockRequest) (*BlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlock not implemented") +} +func (UnimplementedOldFaithfulServer) GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransaction not implemented") +} +func (UnimplementedOldFaithfulServer) mustEmbedUnimplementedOldFaithfulServer() {} + +// UnsafeOldFaithfulServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to OldFaithfulServer will +// result in compilation errors. +type UnsafeOldFaithfulServer interface { + mustEmbedUnimplementedOldFaithfulServer() +} + +func RegisterOldFaithfulServer(s grpc.ServiceRegistrar, srv OldFaithfulServer) { + s.RegisterService(&OldFaithful_ServiceDesc, srv) +} + +func _OldFaithful_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VersionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OldFaithfulServer).GetVersion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: OldFaithful_GetVersion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OldFaithfulServer).GetVersion(ctx, req.(*VersionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OldFaithful_GetBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OldFaithfulServer).GetBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: OldFaithful_GetBlock_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OldFaithfulServer).GetBlock(ctx, req.(*BlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OldFaithful_GetTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OldFaithfulServer).GetTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: OldFaithful_GetTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OldFaithfulServer).GetTransaction(ctx, req.(*TransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// OldFaithful_ServiceDesc is the grpc.ServiceDesc for OldFaithful service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var OldFaithful_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "OldFaithful.OldFaithful", + HandlerType: (*OldFaithfulServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetVersion", + Handler: _OldFaithful_GetVersion_Handler, + }, + { + MethodName: "GetBlock", + Handler: _OldFaithful_GetBlock_Handler, + }, + { + MethodName: "GetTransaction", + Handler: _OldFaithful_GetTransaction_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "old-faithful.proto", +} diff --git a/old-faithful-proto/proto/old-faithful.proto b/old-faithful-proto/proto/old-faithful.proto index bfc1c675..0b24dbae 100644 --- a/old-faithful-proto/proto/old-faithful.proto +++ b/old-faithful-proto/proto/old-faithful.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package OldFaithful; +option go_package = "github.com/rpcpool/yellowstone-faithful/old-faithful-proto;old_faithful_grpc"; service OldFaithful { rpc GetVersion(VersionRequest) returns (VersionResponse); @@ -13,6 +14,8 @@ message VersionRequest {} message VersionResponse { string version = 1; + string commit = 2; + repeated uint64 epochs = 3; } message BlockRequest { @@ -27,7 +30,7 @@ message BlockResponse { int64 block_time = 5; uint64 block_height = 6; repeated Transaction transactions = 7; - repeated bytes rewards = 8; + bytes rewards = 8; } message TransactionRequest { @@ -38,9 +41,11 @@ message TransactionResponse { Transaction transaction = 1; uint64 slot = 2; int64 block_time = 3; + uint64 position = 4; } message Transaction { bytes transaction = 1; bytes meta = 2; // bincode or protobuf + uint64 position = 4; } diff --git a/storage.go b/storage.go index ddc4995a..05cf8565 100644 --- a/storage.go +++ b/storage.go @@ -210,3 +210,26 @@ func parseTransactionAndMetaFromNode( } return } + +func getTransactionAndMetaFromNode( + transactionNode *ipldbindcode.Transaction, + dataFrameGetter func(ctx context.Context, wantedCid cid.Cid) (*ipldbindcode.DataFrame, error), +) ([]byte, []byte, error) { + transactionBuffer, err := loadDataFromDataFrames(&transactionNode.Data, dataFrameGetter) + if err != nil { + return nil, nil, fmt.Errorf("failed to load transaction: %w", err) + } + + metaBuffer, err := loadDataFromDataFrames(&transactionNode.Metadata, dataFrameGetter) + if err != nil { + return nil, nil, fmt.Errorf("failed to load metadata: %w", err) + } + if len(metaBuffer) > 0 { + uncompressedMeta, err := decompressZstd(metaBuffer) + if err != nil { + return nil, nil, fmt.Errorf("failed to decompress metadata: %w", err) + } + return transactionBuffer, uncompressedMeta, nil + } + return transactionBuffer, nil, nil +} diff --git a/txstatus/.gitignore b/txstatus/.gitignore index c3af8579..5997cc94 100644 --- a/txstatus/.gitignore +++ b/txstatus/.gitignore @@ -1 +1,2 @@ lib/ +target/ From 21d739316bd9c54f05781059e4c22125f68cbaeb Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Thu, 6 Jun 2024 14:50:10 +0200 Subject: [PATCH 2/5] Fix proto --- grpc-server.go | 11 ++- .../old-faithful-grpc/old-faithful.pb.go | 84 ++++++++++--------- old-faithful-proto/proto/old-faithful.proto | 10 +-- 3 files changed, 56 insertions(+), 49 deletions(-) diff --git a/grpc-server.go b/grpc-server.go index 36b6eb86..45d2d4ee 100644 --- a/grpc-server.go +++ b/grpc-server.go @@ -203,7 +203,6 @@ func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc } } } - blocktime := uint64(block.Meta.Blocktime) allTransactionNodes := make([][]*ipldbindcode.Transaction, len(block.Entries)) mu := &sync.Mutex{} @@ -293,7 +292,7 @@ func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc { pos, ok := transactionNode.GetPositionIndex() if ok { - txResp.Position = uint64(pos) + txResp.Position = ptrToUint64(uint64(pos)) } txResp.Transaction, txResp.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) if err != nil { @@ -306,10 +305,14 @@ func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc } sort.Slice(allTransactions, func(i, j int) bool { - return allTransactions[i].Position < allTransactions[j].Position + if allTransactions[i].Position == nil || allTransactions[j].Position == nil { + return false + } + return *allTransactions[i].Position < *allTransactions[j].Position }) tim.time("get transactions") resp.Transactions = allTransactions + blocktime := uint64(block.Meta.Blocktime) if blocktime != 0 { resp.BlockTime = int64(blocktime) } @@ -418,7 +421,7 @@ func (multi *MultiEpoch) GetTransaction(ctx context.Context, params *old_faithfu { pos, ok := transactionNode.GetPositionIndex() if ok { - response.Position = uint64(pos) + response.Position = ptrToUint64(uint64(pos)) } response.Transaction.Transaction, response.Transaction.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) if err != nil { diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go index 1e6379d0..6ace2a56 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go @@ -180,7 +180,7 @@ type BlockResponse struct { BlockTime int64 `protobuf:"varint,5,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` BlockHeight uint64 `protobuf:"varint,6,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` Transactions []*Transaction `protobuf:"bytes,7,rep,name=transactions,proto3" json:"transactions,omitempty"` - Rewards []byte `protobuf:"bytes,8,opt,name=rewards,proto3" json:"rewards,omitempty"` + Rewards []byte `protobuf:"bytes,8,opt,name=rewards,proto3" json:"rewards,omitempty"` // protobuf or bincode (or empty) } func (x *BlockResponse) Reset() { @@ -326,7 +326,7 @@ type TransactionResponse struct { Transaction *Transaction `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` Slot uint64 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"` BlockTime int64 `protobuf:"varint,3,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` - Position uint64 `protobuf:"varint,4,opt,name=position,proto3" json:"position,omitempty"` + Position *uint64 `protobuf:"varint,4,opt,name=position,proto3,oneof" json:"position,omitempty"` // position in the block } func (x *TransactionResponse) Reset() { @@ -383,8 +383,8 @@ func (x *TransactionResponse) GetBlockTime() int64 { } func (x *TransactionResponse) GetPosition() uint64 { - if x != nil { - return x.Position + if x != nil && x.Position != nil { + return *x.Position } return 0 } @@ -394,9 +394,9 @@ type Transaction struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` - Meta []byte `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"` // bincode or protobuf - Position uint64 `protobuf:"varint,4,opt,name=position,proto3" json:"position,omitempty"` + Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` // solana native transaction + Meta []byte `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"` // bincode or protobuf + Position *uint64 `protobuf:"varint,4,opt,name=position,proto3,oneof" json:"position,omitempty"` // position in the block } func (x *Transaction) Reset() { @@ -446,8 +446,8 @@ func (x *Transaction) GetMeta() []byte { } func (x *Transaction) GetPosition() uint64 { - if x != nil { - return x.Position + if x != nil && x.Position != nil { + return *x.Position } return 0 } @@ -488,7 +488,7 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x64, 0x73, 0x22, 0x32, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xa0, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xb2, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, @@ -496,36 +496,38 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x5f, 0x0a, 0x0b, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, - 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x1a, - 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xee, 0x01, 0x0a, 0x0b, 0x4f, - 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, 0x47, 0x65, - 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, - 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, - 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, - 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, - 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, - 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, - 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, 0x4c, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, 0x6f, 0x6f, - 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, 0x66, 0x61, - 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, - 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x61, - 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1f, 0x0a, + 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, + 0x00, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0b, + 0x0a, 0x09, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x71, 0x0a, 0x0b, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, + 0x12, 0x1f, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x04, 0x48, 0x00, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, + 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xee, + 0x01, 0x0a, 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, + 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, + 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, + 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, + 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, + 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, + 0x63, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, + 0x65, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, + 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, + 0x64, 0x5f, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -657,6 +659,8 @@ func file_old_faithful_proto_init() { } } } + file_old_faithful_proto_msgTypes[5].OneofWrappers = []interface{}{} + file_old_faithful_proto_msgTypes[6].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/old-faithful-proto/proto/old-faithful.proto b/old-faithful-proto/proto/old-faithful.proto index 0b24dbae..f6db448b 100644 --- a/old-faithful-proto/proto/old-faithful.proto +++ b/old-faithful-proto/proto/old-faithful.proto @@ -30,7 +30,7 @@ message BlockResponse { int64 block_time = 5; uint64 block_height = 6; repeated Transaction transactions = 7; - bytes rewards = 8; + bytes rewards = 8; // protobuf or bincode (or empty) } message TransactionRequest { @@ -41,11 +41,11 @@ message TransactionResponse { Transaction transaction = 1; uint64 slot = 2; int64 block_time = 3; - uint64 position = 4; + optional uint64 position = 4; // position in the block } message Transaction { - bytes transaction = 1; - bytes meta = 2; // bincode or protobuf - uint64 position = 4; + bytes transaction = 1; // solana native transaction + bytes meta = 2; // bincode or protobuf + optional uint64 position = 4; // position in the block } From 0d240138b29b63d36fa748963fe3976acf9b82a9 Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Thu, 6 Jun 2024 15:04:47 +0200 Subject: [PATCH 3/5] Make each server optional --- cmd-rpc.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd-rpc.go b/cmd-rpc.go index 7f0ee63b..80e40c1f 100644 --- a/cmd-rpc.go +++ b/cmd-rpc.go @@ -45,13 +45,13 @@ func newCmd_rpc() *cli.Command { &cli.StringFlag{ Name: "listen", Usage: "Listen address", - Value: ":8899", + Value: "", // If empty, JSON RPC server is not started Destination: &listenOn, }, &cli.StringFlag{ Name: "grpc-listen", Usage: "Listen address for gRPC", - Value: ":8898", + Value: "", // If empty, gRPC server is not started Destination: &grpcListenOn, }, &cli.BoolFlag{ @@ -104,6 +104,9 @@ func newCmd_rpc() *cli.Command { }, ), Action: func(c *cli.Context) error { + if listenOn == "" && grpcListenOn == "" { + return cli.Exit("either --listen or --grpc-listen must be provided (or both)", 1) + } src := c.Args().Slice() configFiles, err := GetListOfConfigFiles( src, @@ -331,13 +334,15 @@ func newCmd_rpc() *cli.Command { return nil }) } - allListeners.Go(func() error { - err := multi.ListenAndServe(c.Context, listenOn, listenerConfig) - if err != nil { - return fmt.Errorf("failed to start JSON RPC server: %w", err) - } - return nil - }) + if listenOn != "" { + allListeners.Go(func() error { + err := multi.ListenAndServe(c.Context, listenOn, listenerConfig) + if err != nil { + return fmt.Errorf("failed to start JSON RPC server: %w", err) + } + return nil + }) + } return allListeners.Wait() }, From 5222830f2934f922e1362184d26bb0f07cc8be7f Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Thu, 6 Jun 2024 21:33:10 +0200 Subject: [PATCH 4/5] Implement feedback --- grpc-server.go | 10 +- .../old-faithful-grpc/old-faithful.pb.go | 108 +++++++----------- old-faithful-proto/proto/old-faithful.proto | 10 +- 3 files changed, 52 insertions(+), 76 deletions(-) diff --git a/grpc-server.go b/grpc-server.go index 45d2d4ee..153c2b10 100644 --- a/grpc-server.go +++ b/grpc-server.go @@ -55,8 +55,6 @@ func (me *MultiEpoch) GetVersion(context.Context, *old_faithful_grpc.VersionRequ } return GitTag }(), - Commit: GitCommit, - Epochs: me.GetEpochNumbers(), } return resp, nil } @@ -292,7 +290,7 @@ func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc { pos, ok := transactionNode.GetPositionIndex() if ok { - txResp.Position = ptrToUint64(uint64(pos)) + txResp.Index = ptrToUint64(uint64(pos)) } txResp.Transaction, txResp.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) if err != nil { @@ -305,10 +303,10 @@ func (multi *MultiEpoch) GetBlock(ctx context.Context, params *old_faithful_grpc } sort.Slice(allTransactions, func(i, j int) bool { - if allTransactions[i].Position == nil || allTransactions[j].Position == nil { + if allTransactions[i].Index == nil || allTransactions[j].Index == nil { return false } - return *allTransactions[i].Position < *allTransactions[j].Position + return *allTransactions[i].Index < *allTransactions[j].Index }) tim.time("get transactions") resp.Transactions = allTransactions @@ -421,7 +419,7 @@ func (multi *MultiEpoch) GetTransaction(ctx context.Context, params *old_faithfu { pos, ok := transactionNode.GetPositionIndex() if ok { - response.Position = ptrToUint64(uint64(pos)) + response.Index = ptrToUint64(uint64(pos)) } response.Transaction.Transaction, response.Transaction.Meta, err = getTransactionAndMetaFromNode(transactionNode, epochHandler.GetDataFrameByCid) if err != nil { diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go index 6ace2a56..7582fa9e 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go @@ -63,9 +63,7 @@ type VersionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - Commit string `protobuf:"bytes,2,opt,name=commit,proto3" json:"commit,omitempty"` - Epochs []uint64 `protobuf:"varint,3,rep,packed,name=epochs,proto3" json:"epochs,omitempty"` + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` } func (x *VersionResponse) Reset() { @@ -107,20 +105,6 @@ func (x *VersionResponse) GetVersion() string { return "" } -func (x *VersionResponse) GetCommit() string { - if x != nil { - return x.Commit - } - return "" -} - -func (x *VersionResponse) GetEpochs() []uint64 { - if x != nil { - return x.Epochs - } - return nil -} - type BlockRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -326,7 +310,7 @@ type TransactionResponse struct { Transaction *Transaction `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` Slot uint64 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"` BlockTime int64 `protobuf:"varint,3,opt,name=block_time,json=blockTime,proto3" json:"block_time,omitempty"` - Position *uint64 `protobuf:"varint,4,opt,name=position,proto3,oneof" json:"position,omitempty"` // position in the block + Index *uint64 `protobuf:"varint,4,opt,name=index,proto3,oneof" json:"index,omitempty"` // position in the block } func (x *TransactionResponse) Reset() { @@ -382,9 +366,9 @@ func (x *TransactionResponse) GetBlockTime() int64 { return 0 } -func (x *TransactionResponse) GetPosition() uint64 { - if x != nil && x.Position != nil { - return *x.Position +func (x *TransactionResponse) GetIndex() uint64 { + if x != nil && x.Index != nil { + return *x.Index } return 0 } @@ -394,9 +378,9 @@ type Transaction struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` // solana native transaction - Meta []byte `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"` // bincode or protobuf - Position *uint64 `protobuf:"varint,4,opt,name=position,proto3,oneof" json:"position,omitempty"` // position in the block + Transaction []byte `protobuf:"bytes,1,opt,name=transaction,proto3" json:"transaction,omitempty"` // solana native transaction + Meta []byte `protobuf:"bytes,2,opt,name=meta,proto3" json:"meta,omitempty"` // bincode or protobuf + Index *uint64 `protobuf:"varint,4,opt,name=index,proto3,oneof" json:"index,omitempty"` // position in the block } func (x *Transaction) Reset() { @@ -445,9 +429,9 @@ func (x *Transaction) GetMeta() []byte { return nil } -func (x *Transaction) GetPosition() uint64 { - if x != nil && x.Position != nil { - return *x.Position +func (x *Transaction) GetIndex() uint64 { + if x != nil && x.Index != nil { + return *x.Index } return 0 } @@ -458,12 +442,9 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x0a, 0x12, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x22, 0x10, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x5b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x65, 0x73, 0x74, 0x22, 0x2b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x73, 0x22, 0x22, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x22, 0xab, 0x02, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, @@ -488,7 +469,7 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x64, 0x73, 0x22, 0x32, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xb2, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xa9, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, @@ -496,38 +477,37 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1f, 0x0a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, - 0x00, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0b, - 0x0a, 0x09, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x71, 0x0a, 0x0b, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, - 0x12, 0x1f, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x04, 0x48, 0x00, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, - 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xee, - 0x01, 0x0a, 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, - 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, - 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, - 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, - 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, - 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, - 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, - 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, - 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, - 0x63, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, - 0x65, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, - 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, - 0x64, 0x5f, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x03, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, + 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x05, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x22, 0x68, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x19, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x88, + 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x32, 0xee, 0x01, 0x0a, + 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, + 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, + 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, + 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, + 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, + 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, + 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, + 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, + 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/old-faithful-proto/proto/old-faithful.proto b/old-faithful-proto/proto/old-faithful.proto index f6db448b..efd1c8ee 100644 --- a/old-faithful-proto/proto/old-faithful.proto +++ b/old-faithful-proto/proto/old-faithful.proto @@ -14,8 +14,6 @@ message VersionRequest {} message VersionResponse { string version = 1; - string commit = 2; - repeated uint64 epochs = 3; } message BlockRequest { @@ -41,11 +39,11 @@ message TransactionResponse { Transaction transaction = 1; uint64 slot = 2; int64 block_time = 3; - optional uint64 position = 4; // position in the block + optional uint64 index = 4; // position in the block } message Transaction { - bytes transaction = 1; // solana native transaction - bytes meta = 2; // bincode or protobuf - optional uint64 position = 4; // position in the block + bytes transaction = 1; // solana native transaction + bytes meta = 2; // bincode or protobuf + optional uint64 index = 4; // position in the block } From e433d6628a14a34bcebca4c37df6f425ef805dd9 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Wed, 12 Jun 2024 09:51:36 -0400 Subject: [PATCH 5/5] grpc: add bidi stream (#104) Co-authored-by: gagliardetto --- grpc-server.go | 131 +++++ .../old-faithful-grpc/old-faithful.pb.go | 540 ++++++++++++++++-- .../old-faithful-grpc/old-faithful_grpc.pb.go | 73 ++- old-faithful-proto/proto/old-faithful.proto | 31 + 4 files changed, 718 insertions(+), 57 deletions(-) diff --git a/grpc-server.go b/grpc-server.go index 153c2b10..7d98bf7b 100644 --- a/grpc-server.go +++ b/grpc-server.go @@ -429,3 +429,134 @@ func (multi *MultiEpoch) GetTransaction(ctx context.Context, params *old_faithfu return response, nil } + +func (multi *MultiEpoch) Get(ser old_faithful_grpc.OldFaithful_GetServer) error { + ctx := ser.Context() + + for { + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + req, err := ser.Recv() + if err != nil { + if errors.Is(err, io.EOF) { + return nil + } + return err + } + id := req.GetId() + + switch req.Request.(type) { + case *old_faithful_grpc.GetRequest_Block: + params := req.GetBlock() + resp, err := multi.GetBlock(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send block error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get block: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Block{Block: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send block response: %v", id, err) + } + case *old_faithful_grpc.GetRequest_Transaction: + params := req.GetTransaction() + resp, err := multi.GetTransaction(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send transaction error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get transaction: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Transaction{Transaction: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send transaction response: %v", id, err) + } + case *old_faithful_grpc.GetRequest_Version: + params := req.GetVersion() + resp, err := multi.GetVersion(ctx, params) + if err != nil { + gerr, ok := status.FromError(err) + if ok { + err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Error{ + Error: &old_faithful_grpc.GetResponseError{ + Code: func() old_faithful_grpc.GetResponseErrorCode { + switch gerr.Code() { + case codes.NotFound: + return old_faithful_grpc.GetResponseErrorCode_NOT_FOUND + default: + return old_faithful_grpc.GetResponseErrorCode_INTERNAL + } + }(), + Message: gerr.Message(), + }, + }, + }) + if err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send version error response: %v", id, err) + } + continue + } + return status.Errorf(codes.Internal, "request %d; failed to get version: %v", id, err) + } + if err := ser.Send(&old_faithful_grpc.GetResponse{ + Id: id, + Response: &old_faithful_grpc.GetResponse_Version{Version: resp}, + }); err != nil { + return status.Errorf(codes.Internal, "request %d; failed to send version response: %v", id, err) + } + default: + return status.Errorf(codes.InvalidArgument, "unknown request type %T", req.Request) + } + } +} diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go index 7582fa9e..f82ad7bc 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.1 // source: old-faithful.proto @@ -20,6 +20,52 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type GetResponseErrorCode int32 + +const ( + GetResponseErrorCode_INTERNAL GetResponseErrorCode = 0 + GetResponseErrorCode_NOT_FOUND GetResponseErrorCode = 1 +) + +// Enum value maps for GetResponseErrorCode. +var ( + GetResponseErrorCode_name = map[int32]string{ + 0: "INTERNAL", + 1: "NOT_FOUND", + } + GetResponseErrorCode_value = map[string]int32{ + "INTERNAL": 0, + "NOT_FOUND": 1, + } +) + +func (x GetResponseErrorCode) Enum() *GetResponseErrorCode { + p := new(GetResponseErrorCode) + *p = x + return p +} + +func (x GetResponseErrorCode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (GetResponseErrorCode) Descriptor() protoreflect.EnumDescriptor { + return file_old_faithful_proto_enumTypes[0].Descriptor() +} + +func (GetResponseErrorCode) Type() protoreflect.EnumType { + return &file_old_faithful_proto_enumTypes[0] +} + +func (x GetResponseErrorCode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use GetResponseErrorCode.Descriptor instead. +func (GetResponseErrorCode) EnumDescriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{0} +} + type VersionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -436,6 +482,281 @@ func (x *Transaction) GetIndex() uint64 { return 0 } +type GetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Types that are assignable to Request: + // + // *GetRequest_Version + // *GetRequest_Block + // *GetRequest_Transaction + Request isGetRequest_Request `protobuf_oneof:"request"` +} + +func (x *GetRequest) Reset() { + *x = GetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequest) ProtoMessage() {} + +func (x *GetRequest) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead. +func (*GetRequest) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{7} +} + +func (x *GetRequest) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (m *GetRequest) GetRequest() isGetRequest_Request { + if m != nil { + return m.Request + } + return nil +} + +func (x *GetRequest) GetVersion() *VersionRequest { + if x, ok := x.GetRequest().(*GetRequest_Version); ok { + return x.Version + } + return nil +} + +func (x *GetRequest) GetBlock() *BlockRequest { + if x, ok := x.GetRequest().(*GetRequest_Block); ok { + return x.Block + } + return nil +} + +func (x *GetRequest) GetTransaction() *TransactionRequest { + if x, ok := x.GetRequest().(*GetRequest_Transaction); ok { + return x.Transaction + } + return nil +} + +type isGetRequest_Request interface { + isGetRequest_Request() +} + +type GetRequest_Version struct { + Version *VersionRequest `protobuf:"bytes,2,opt,name=version,proto3,oneof"` +} + +type GetRequest_Block struct { + Block *BlockRequest `protobuf:"bytes,3,opt,name=block,proto3,oneof"` +} + +type GetRequest_Transaction struct { + Transaction *TransactionRequest `protobuf:"bytes,4,opt,name=transaction,proto3,oneof"` +} + +func (*GetRequest_Version) isGetRequest_Request() {} + +func (*GetRequest_Block) isGetRequest_Request() {} + +func (*GetRequest_Transaction) isGetRequest_Request() {} + +type GetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Types that are assignable to Response: + // + // *GetResponse_Error + // *GetResponse_Version + // *GetResponse_Block + // *GetResponse_Transaction + Response isGetResponse_Response `protobuf_oneof:"response"` +} + +func (x *GetResponse) Reset() { + *x = GetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResponse) ProtoMessage() {} + +func (x *GetResponse) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead. +func (*GetResponse) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{8} +} + +func (x *GetResponse) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (m *GetResponse) GetResponse() isGetResponse_Response { + if m != nil { + return m.Response + } + return nil +} + +func (x *GetResponse) GetError() *GetResponseError { + if x, ok := x.GetResponse().(*GetResponse_Error); ok { + return x.Error + } + return nil +} + +func (x *GetResponse) GetVersion() *VersionResponse { + if x, ok := x.GetResponse().(*GetResponse_Version); ok { + return x.Version + } + return nil +} + +func (x *GetResponse) GetBlock() *BlockResponse { + if x, ok := x.GetResponse().(*GetResponse_Block); ok { + return x.Block + } + return nil +} + +func (x *GetResponse) GetTransaction() *TransactionResponse { + if x, ok := x.GetResponse().(*GetResponse_Transaction); ok { + return x.Transaction + } + return nil +} + +type isGetResponse_Response interface { + isGetResponse_Response() +} + +type GetResponse_Error struct { + Error *GetResponseError `protobuf:"bytes,2,opt,name=error,proto3,oneof"` +} + +type GetResponse_Version struct { + Version *VersionResponse `protobuf:"bytes,3,opt,name=version,proto3,oneof"` +} + +type GetResponse_Block struct { + Block *BlockResponse `protobuf:"bytes,4,opt,name=block,proto3,oneof"` +} + +type GetResponse_Transaction struct { + Transaction *TransactionResponse `protobuf:"bytes,5,opt,name=transaction,proto3,oneof"` +} + +func (*GetResponse_Error) isGetResponse_Response() {} + +func (*GetResponse_Version) isGetResponse_Response() {} + +func (*GetResponse_Block) isGetResponse_Response() {} + +func (*GetResponse_Transaction) isGetResponse_Response() {} + +type GetResponseError struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code GetResponseErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=OldFaithful.GetResponseErrorCode" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *GetResponseError) Reset() { + *x = GetResponseError{} + if protoimpl.UnsafeEnabled { + mi := &file_old_faithful_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetResponseError) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResponseError) ProtoMessage() {} + +func (x *GetResponseError) ProtoReflect() protoreflect.Message { + mi := &file_old_faithful_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetResponseError.ProtoReflect.Descriptor instead. +func (*GetResponseError) Descriptor() ([]byte, []int) { + return file_old_faithful_proto_rawDescGZIP(), []int{9} +} + +func (x *GetResponseError) GetCode() GetResponseErrorCode { + if x != nil { + return x.Code + } + return GetResponseErrorCode_INTERNAL +} + +func (x *GetResponseError) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_old_faithful_proto protoreflect.FileDescriptor var file_old_faithful_proto_rawDesc = []byte{ @@ -486,28 +807,72 @@ var file_old_faithful_proto_rawDesc = []byte{ 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x19, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x88, - 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x32, 0xee, 0x01, 0x0a, - 0x0b, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, - 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, - 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, - 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, - 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, - 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, - 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4e, 0x5a, - 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, - 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, - 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, - 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, - 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xd8, 0x01, 0x0a, + 0x0a, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x37, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, + 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x43, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x4f, + 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, + 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x94, 0x02, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x35, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x38, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x44, 0x0a, 0x0b, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x0a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x63, + 0x0a, 0x10, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x12, 0x35, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x21, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, + 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2a, 0x33, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x49, + 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x54, + 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x01, 0x32, 0xac, 0x02, 0x0a, 0x0b, 0x4f, 0x6c, 0x64, + 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x12, 0x47, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, + 0x6c, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x41, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x2e, + 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, + 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, + 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, + 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x03, 0x47, 0x65, 0x74, + 0x12, 0x17, 0x2e, 0x4f, 0x6c, 0x64, 0x46, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x4f, 0x6c, 0x64, 0x46, + 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x4e, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x70, 0x63, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x79, 0x65, + 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x74, 0x6f, 0x6e, 0x65, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, + 0x75, 0x6c, 0x2f, 0x6f, 0x6c, 0x64, 0x2d, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, 0x75, 0x6c, 0x2d, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x61, 0x69, 0x74, 0x68, 0x66, + 0x75, 0x6c, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -522,30 +887,45 @@ func file_old_faithful_proto_rawDescGZIP() []byte { return file_old_faithful_proto_rawDescData } -var file_old_faithful_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_old_faithful_proto_goTypes = []interface{}{ - (*VersionRequest)(nil), // 0: OldFaithful.VersionRequest - (*VersionResponse)(nil), // 1: OldFaithful.VersionResponse - (*BlockRequest)(nil), // 2: OldFaithful.BlockRequest - (*BlockResponse)(nil), // 3: OldFaithful.BlockResponse - (*TransactionRequest)(nil), // 4: OldFaithful.TransactionRequest - (*TransactionResponse)(nil), // 5: OldFaithful.TransactionResponse - (*Transaction)(nil), // 6: OldFaithful.Transaction +var file_old_faithful_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_old_faithful_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_old_faithful_proto_goTypes = []any{ + (GetResponseErrorCode)(0), // 0: OldFaithful.GetResponseErrorCode + (*VersionRequest)(nil), // 1: OldFaithful.VersionRequest + (*VersionResponse)(nil), // 2: OldFaithful.VersionResponse + (*BlockRequest)(nil), // 3: OldFaithful.BlockRequest + (*BlockResponse)(nil), // 4: OldFaithful.BlockResponse + (*TransactionRequest)(nil), // 5: OldFaithful.TransactionRequest + (*TransactionResponse)(nil), // 6: OldFaithful.TransactionResponse + (*Transaction)(nil), // 7: OldFaithful.Transaction + (*GetRequest)(nil), // 8: OldFaithful.GetRequest + (*GetResponse)(nil), // 9: OldFaithful.GetResponse + (*GetResponseError)(nil), // 10: OldFaithful.GetResponseError } var file_old_faithful_proto_depIdxs = []int32{ - 6, // 0: OldFaithful.BlockResponse.transactions:type_name -> OldFaithful.Transaction - 6, // 1: OldFaithful.TransactionResponse.transaction:type_name -> OldFaithful.Transaction - 0, // 2: OldFaithful.OldFaithful.GetVersion:input_type -> OldFaithful.VersionRequest - 2, // 3: OldFaithful.OldFaithful.GetBlock:input_type -> OldFaithful.BlockRequest - 4, // 4: OldFaithful.OldFaithful.GetTransaction:input_type -> OldFaithful.TransactionRequest - 1, // 5: OldFaithful.OldFaithful.GetVersion:output_type -> OldFaithful.VersionResponse - 3, // 6: OldFaithful.OldFaithful.GetBlock:output_type -> OldFaithful.BlockResponse - 5, // 7: OldFaithful.OldFaithful.GetTransaction:output_type -> OldFaithful.TransactionResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 7, // 0: OldFaithful.BlockResponse.transactions:type_name -> OldFaithful.Transaction + 7, // 1: OldFaithful.TransactionResponse.transaction:type_name -> OldFaithful.Transaction + 1, // 2: OldFaithful.GetRequest.version:type_name -> OldFaithful.VersionRequest + 3, // 3: OldFaithful.GetRequest.block:type_name -> OldFaithful.BlockRequest + 5, // 4: OldFaithful.GetRequest.transaction:type_name -> OldFaithful.TransactionRequest + 10, // 5: OldFaithful.GetResponse.error:type_name -> OldFaithful.GetResponseError + 2, // 6: OldFaithful.GetResponse.version:type_name -> OldFaithful.VersionResponse + 4, // 7: OldFaithful.GetResponse.block:type_name -> OldFaithful.BlockResponse + 6, // 8: OldFaithful.GetResponse.transaction:type_name -> OldFaithful.TransactionResponse + 0, // 9: OldFaithful.GetResponseError.code:type_name -> OldFaithful.GetResponseErrorCode + 1, // 10: OldFaithful.OldFaithful.GetVersion:input_type -> OldFaithful.VersionRequest + 3, // 11: OldFaithful.OldFaithful.GetBlock:input_type -> OldFaithful.BlockRequest + 5, // 12: OldFaithful.OldFaithful.GetTransaction:input_type -> OldFaithful.TransactionRequest + 8, // 13: OldFaithful.OldFaithful.Get:input_type -> OldFaithful.GetRequest + 2, // 14: OldFaithful.OldFaithful.GetVersion:output_type -> OldFaithful.VersionResponse + 4, // 15: OldFaithful.OldFaithful.GetBlock:output_type -> OldFaithful.BlockResponse + 6, // 16: OldFaithful.OldFaithful.GetTransaction:output_type -> OldFaithful.TransactionResponse + 9, // 17: OldFaithful.OldFaithful.Get:output_type -> OldFaithful.GetResponse + 14, // [14:18] is the sub-list for method output_type + 10, // [10:14] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_old_faithful_proto_init() } @@ -554,7 +934,7 @@ func file_old_faithful_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_old_faithful_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*VersionRequest); i { case 0: return &v.state @@ -566,7 +946,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*VersionResponse); i { case 0: return &v.state @@ -578,7 +958,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*BlockRequest); i { case 0: return &v.state @@ -590,7 +970,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*BlockResponse); i { case 0: return &v.state @@ -602,7 +982,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*TransactionRequest); i { case 0: return &v.state @@ -614,7 +994,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*TransactionResponse); i { case 0: return &v.state @@ -626,7 +1006,7 @@ func file_old_faithful_proto_init() { return nil } } - file_old_faithful_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_old_faithful_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*Transaction); i { case 0: return &v.state @@ -638,21 +1018,69 @@ func file_old_faithful_proto_init() { return nil } } + file_old_faithful_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*GetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*GetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_old_faithful_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*GetResponseError); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_old_faithful_proto_msgTypes[5].OneofWrappers = []any{} + file_old_faithful_proto_msgTypes[6].OneofWrappers = []any{} + file_old_faithful_proto_msgTypes[7].OneofWrappers = []any{ + (*GetRequest_Version)(nil), + (*GetRequest_Block)(nil), + (*GetRequest_Transaction)(nil), + } + file_old_faithful_proto_msgTypes[8].OneofWrappers = []any{ + (*GetResponse_Error)(nil), + (*GetResponse_Version)(nil), + (*GetResponse_Block)(nil), + (*GetResponse_Transaction)(nil), } - file_old_faithful_proto_msgTypes[5].OneofWrappers = []interface{}{} - file_old_faithful_proto_msgTypes[6].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_old_faithful_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, + NumEnums: 1, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, GoTypes: file_old_faithful_proto_goTypes, DependencyIndexes: file_old_faithful_proto_depIdxs, + EnumInfos: file_old_faithful_proto_enumTypes, MessageInfos: file_old_faithful_proto_msgTypes, }.Build() File_old_faithful_proto = out.File diff --git a/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go index 40e16525..9dd448db 100644 --- a/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go +++ b/old-faithful-proto/old-faithful-grpc/old-faithful_grpc.pb.go @@ -22,6 +22,7 @@ const ( OldFaithful_GetVersion_FullMethodName = "/OldFaithful.OldFaithful/GetVersion" OldFaithful_GetBlock_FullMethodName = "/OldFaithful.OldFaithful/GetBlock" OldFaithful_GetTransaction_FullMethodName = "/OldFaithful.OldFaithful/GetTransaction" + OldFaithful_Get_FullMethodName = "/OldFaithful.OldFaithful/Get" ) // OldFaithfulClient is the client API for OldFaithful service. @@ -31,6 +32,7 @@ type OldFaithfulClient interface { GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) GetBlock(ctx context.Context, in *BlockRequest, opts ...grpc.CallOption) (*BlockResponse, error) GetTransaction(ctx context.Context, in *TransactionRequest, opts ...grpc.CallOption) (*TransactionResponse, error) + Get(ctx context.Context, opts ...grpc.CallOption) (OldFaithful_GetClient, error) } type oldFaithfulClient struct { @@ -71,6 +73,38 @@ func (c *oldFaithfulClient) GetTransaction(ctx context.Context, in *TransactionR return out, nil } +func (c *oldFaithfulClient) Get(ctx context.Context, opts ...grpc.CallOption) (OldFaithful_GetClient, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &OldFaithful_ServiceDesc.Streams[0], OldFaithful_Get_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &oldFaithfulGetClient{ClientStream: stream} + return x, nil +} + +type OldFaithful_GetClient interface { + Send(*GetRequest) error + Recv() (*GetResponse, error) + grpc.ClientStream +} + +type oldFaithfulGetClient struct { + grpc.ClientStream +} + +func (x *oldFaithfulGetClient) Send(m *GetRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *oldFaithfulGetClient) Recv() (*GetResponse, error) { + m := new(GetResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // OldFaithfulServer is the server API for OldFaithful service. // All implementations must embed UnimplementedOldFaithfulServer // for forward compatibility @@ -78,6 +112,7 @@ type OldFaithfulServer interface { GetVersion(context.Context, *VersionRequest) (*VersionResponse, error) GetBlock(context.Context, *BlockRequest) (*BlockResponse, error) GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) + Get(OldFaithful_GetServer) error mustEmbedUnimplementedOldFaithfulServer() } @@ -94,6 +129,9 @@ func (UnimplementedOldFaithfulServer) GetBlock(context.Context, *BlockRequest) ( func (UnimplementedOldFaithfulServer) GetTransaction(context.Context, *TransactionRequest) (*TransactionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetTransaction not implemented") } +func (UnimplementedOldFaithfulServer) Get(OldFaithful_GetServer) error { + return status.Errorf(codes.Unimplemented, "method Get not implemented") +} func (UnimplementedOldFaithfulServer) mustEmbedUnimplementedOldFaithfulServer() {} // UnsafeOldFaithfulServer may be embedded to opt out of forward compatibility for this service. @@ -161,6 +199,32 @@ func _OldFaithful_GetTransaction_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _OldFaithful_Get_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(OldFaithfulServer).Get(&oldFaithfulGetServer{ServerStream: stream}) +} + +type OldFaithful_GetServer interface { + Send(*GetResponse) error + Recv() (*GetRequest, error) + grpc.ServerStream +} + +type oldFaithfulGetServer struct { + grpc.ServerStream +} + +func (x *oldFaithfulGetServer) Send(m *GetResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *oldFaithfulGetServer) Recv() (*GetRequest, error) { + m := new(GetRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // OldFaithful_ServiceDesc is the grpc.ServiceDesc for OldFaithful service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -181,6 +245,13 @@ var OldFaithful_ServiceDesc = grpc.ServiceDesc{ Handler: _OldFaithful_GetTransaction_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Get", + Handler: _OldFaithful_Get_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, Metadata: "old-faithful.proto", } diff --git a/old-faithful-proto/proto/old-faithful.proto b/old-faithful-proto/proto/old-faithful.proto index efd1c8ee..f089a4d8 100644 --- a/old-faithful-proto/proto/old-faithful.proto +++ b/old-faithful-proto/proto/old-faithful.proto @@ -8,6 +8,8 @@ service OldFaithful { rpc GetBlock(BlockRequest) returns (BlockResponse); rpc GetTransaction(TransactionRequest) returns (TransactionResponse); + + rpc Get(stream GetRequest) returns (stream GetResponse); } message VersionRequest {} @@ -47,3 +49,32 @@ message Transaction { bytes meta = 2; // bincode or protobuf optional uint64 index = 4; // position in the block } + +message GetRequest { + uint64 id = 1; + oneof request { + VersionRequest version = 2; + BlockRequest block = 3; + TransactionRequest transaction = 4; + } +} + +message GetResponse { + uint64 id = 1; + oneof response { + GetResponseError error = 2; + VersionResponse version = 3; + BlockResponse block = 4; + TransactionResponse transaction = 5; + } +} + +enum GetResponseErrorCode { + INTERNAL = 0; + NOT_FOUND = 1; +} + +message GetResponseError { + GetResponseErrorCode code = 1; + string message = 2; +}