Skip to content

Commit

Permalink
Add proper version command (#63)
Browse files Browse the repository at this point in the history
* Add proper version command

Adds version command compatible with web3.js

* Formatting
  • Loading branch information
linuskendall authored Nov 15, 2023
1 parent beb04e4 commit 69aa3e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions multiepoch-getVersion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
12 changes: 9 additions & 3 deletions multiepoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 69aa3e2

Please sign in to comment.