From 658be274eff1232b94859f5da4a846d3cdddce6f Mon Sep 17 00:00:00 2001 From: linuskendall Date: Sat, 19 Aug 2023 09:11:49 +0100 Subject: [PATCH] Added getVersion placeholder Implementation of https://github.com/rpcpool/yellowstone-faithful/pull/38 on the multiepoch time. --- multiepoch-getVersion.go | 31 +++++++++++++++++++++++++++++++ multiepoch.go | 2 ++ storage.go | 5 +++++ 3 files changed, 38 insertions(+) create mode 100644 multiepoch-getVersion.go diff --git a/multiepoch-getVersion.go b/multiepoch-getVersion.go new file mode 100644 index 00000000..e3eaffca --- /dev/null +++ b/multiepoch-getVersion.go @@ -0,0 +1,31 @@ +package main + +import ( + "context" + "fmt" + + "github.com/sourcegraph/jsonrpc2" +) + +// @TODO make these values make sense +func (ser *MultiEpoch) handleGetVersion(ctx context.Context, conn *requestContext, req *jsonrpc2.Request) (*jsonrpc2.Error, error) { + // taken from solana mainnet version reponse + var versionResponse GetVersionResponse + versionResponse.FeatureSet = 1879391783 + versionResponse.SolanaCore = "1.14.23" + var err = conn.Reply( + ctx, + req.ID, + versionResponse, + func(m map[string]any) map[string]any { + r := map[string]any{} + r["feature-set"] = m["featureSet"] + r["solana-core"] = m["solanaCore"] + return r + }, + ) + if err != nil { + return nil, fmt.Errorf("failed to reply: %w", err) + } + return nil, nil +} diff --git a/multiepoch.go b/multiepoch.go index 2cfbb9c6..0f9a99e1 100644 --- a/multiepoch.go +++ b/multiepoch.go @@ -355,6 +355,8 @@ func (ser *MultiEpoch) handleRequest(ctx context.Context, conn *requestContext, return ser.handleGetTransaction(ctx, conn, req) case "getSignaturesForAddress": return ser.handleGetSignaturesForAddress(ctx, conn, req) + case "getVersion": + return ser.handleGetVersion(ctx, conn, req) default: return &jsonrpc2.Error{ Code: jsonrpc2.CodeMethodNotFound, diff --git a/storage.go b/storage.go index 62b1493b..2d0d760c 100644 --- a/storage.go +++ b/storage.go @@ -125,6 +125,11 @@ type GetTransactionResponse struct { Signatures []solana.Signature `json:"-"` // TODO: enable this } +type GetVersionResponse struct { + FeatureSet uint64 `json:"feature-set"` + SolanaCore string `json:"solana-core"` +} + func loadDataFromDataFrames( firstDataFrame *ipldbindcode.DataFrame, dataFrameGetter func(ctx context.Context, wantedCid cid.Cid) (*ipldbindcode.DataFrame, error),