Skip to content

Commit

Permalink
Merge pull request #773 from The-K-R-O-K/illia-malachyn/761-get-node-…
Browse files Browse the repository at this point in the history
…version-info-response

Update GetNodeVersionInfo response object
  • Loading branch information
peterargue authored Oct 9, 2024
2 parents 785d4b6 + 5ba957d commit 853e844
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions access/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,23 @@ func (c *BaseClient) GetNodeVersionInfo(ctx context.Context, opts ...grpc.CallOp
return nil, newRPCError(err)
}

var compRange *flow.CompatibleRange
info := res.GetInfo()
if info != nil {
compRange = &flow.CompatibleRange{
StartHeight: info.CompatibleRange.GetStartHeight(),
EndHeight: info.CompatibleRange.GetEndHeight(),
}
}

return &flow.NodeVersionInfo{
Semver: info.Semver,
Commit: info.Commit,
SporkId: flow.BytesToID(info.SporkId),
ProtocolVersion: info.ProtocolVersion,
SporkRootBlockHeight: info.SporkRootBlockHeight,
NodeRootBlockHeight: info.NodeRootBlockHeight,
CompatibleRange: compRange,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions access/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ver := uint64(1)
spork := uint64(2)
root := uint64(3)
compRange := &entities.CompatibleRange{StartHeight: 1, EndHeight: 10}

response := &access.GetNodeVersionInfoResponse{
Info: &entities.NodeVersionInfo{
Expand All @@ -165,6 +166,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ProtocolVersion: ver,
SporkRootBlockHeight: spork,
NodeRootBlockHeight: root,
CompatibleRange: compRange,
},
}

Expand All @@ -175,6 +177,7 @@ func TestClient_GetNodeInfo(t *testing.T) {
ProtocolVersion: ver,
SporkRootBlockHeight: spork,
NodeRootBlockHeight: root,
CompatibleRange: &flow.CompatibleRange{StartHeight: compRange.StartHeight, EndHeight: compRange.EndHeight},
}

rpc.On("GetNodeVersionInfo", ctx, mock.Anything).Return(response, nil)
Expand Down
6 changes: 6 additions & 0 deletions flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ type NodeVersionInfo struct {
ProtocolVersion uint64
SporkRootBlockHeight uint64
NodeRootBlockHeight uint64
CompatibleRange *CompatibleRange
}

type CompatibleRange struct {
StartHeight uint64
EndHeight uint64
}

// entityHasher is a thread-safe hasher used to hash Flow entities.
Expand Down

0 comments on commit 853e844

Please sign in to comment.