From 356f35dae938ab94c166451f8c6b53212761876f Mon Sep 17 00:00:00 2001 From: linuskendall Date: Mon, 6 Nov 2023 01:43:38 +0000 Subject: [PATCH 1/2] Add proper version command Adds version command compatible with web3.js --- multiepoch-getVersion.go | 8 ++++++++ multiepoch.go | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/multiepoch-getVersion.go b/multiepoch-getVersion.go index ec81839d..9201c56e 100644 --- a/multiepoch-getVersion.go +++ b/multiepoch-getVersion.go @@ -46,3 +46,11 @@ func (ser *MultiEpoch) GetFaithfulVersionInfo() map[string]any { faithfulVersion["epochs"] = ser.GetEpochNumbers() return faithfulVersion } + +// This function should return the solana version we are compatible with +func (ser *MultiEpoch) GetSolanaVersionInfo() map[string]any { + solanaVersion := make(map[string]any) + solanaVersion["feature-set"] = 1879391783 + solanaVersion["solana-core"] = "1.16.7" + return solanaVersion +} diff --git a/multiepoch.go b/multiepoch.go index 79628ae4..f7a2dbbc 100644 --- a/multiepoch.go +++ b/multiepoch.go @@ -298,13 +298,19 @@ func newMultiEpochHandler(handler *MultiEpoch, lsConf *ListenerConfig) func(ctx method := rpcRequest.Method if method == "getVersion" { + versionInfo := make(map[string]any) faithfulVersion := handler.GetFaithfulVersionInfo() + versionInfo["faithful"] = faithfulVersion + + solanaVersion := handler.GetSolanaVersionInfo() + for k,v := range solanaVersion { + versionInfo[k] = v + } + err := rqCtx.ReplyRaw( reqCtx, rpcRequest.ID, - map[string]any{ - "faithful": faithfulVersion, - }, + versionInfo, ) if err != nil { klog.Errorf("[%s] failed to reply to getVersion: %v", reqID, err) From 167e8d0596bd5293b0f01e0c9251e9708c8a9b13 Mon Sep 17 00:00:00 2001 From: linuskendall Date: Wed, 15 Nov 2023 13:41:30 +0000 Subject: [PATCH 2/2] Formatting --- multiepoch.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/multiepoch.go b/multiepoch.go index f7a2dbbc..7408d098 100644 --- a/multiepoch.go +++ b/multiepoch.go @@ -298,19 +298,19 @@ func newMultiEpochHandler(handler *MultiEpoch, lsConf *ListenerConfig) func(ctx method := rpcRequest.Method if method == "getVersion" { - versionInfo := make(map[string]any) + versionInfo := make(map[string]any) faithfulVersion := handler.GetFaithfulVersionInfo() - versionInfo["faithful"] = faithfulVersion + versionInfo["faithful"] = faithfulVersion - solanaVersion := handler.GetSolanaVersionInfo() - for k,v := range solanaVersion { - versionInfo[k] = v - } + solanaVersion := handler.GetSolanaVersionInfo() + for k, v := range solanaVersion { + versionInfo[k] = v + } err := rqCtx.ReplyRaw( reqCtx, rpcRequest.ID, - versionInfo, + versionInfo, ) if err != nil { klog.Errorf("[%s] failed to reply to getVersion: %v", reqID, err)