Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GetNodeVersionInfo response object #773

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading