Fix getBlockProduction identity param

This commit is contained in:
Richard Patel 2021-10-20 16:58:27 +02:00
parent 07e95b99cd
commit 4a6bf38d67
2 changed files with 10 additions and 10 deletions

View File

@ -590,8 +590,8 @@ func TestClient_GetBlockProductionWithOpts(t *testing.T) {
Range: &SlotRangeRequest{
FirstSlot: firstSlot,
LastSlot: &lastSlot,
Identity: &identity,
},
Identity: &identity,
},
)
require.NoError(t, err)
@ -607,8 +607,8 @@ func TestClient_GetBlockProductionWithOpts(t *testing.T) {
"range": map[string]interface{}{
"firstSlot": float64(firstSlot),
"lastSlot": float64(lastSlot),
"identity": string(identity.String()),
},
"identity": identity.String(),
},
},
},

View File

@ -35,6 +35,11 @@ type GetBlockProductionOpts struct {
//
// This parameter is optional.
Range *SlotRangeRequest
// Only return results for this validator identity.
//
// This parameter is optional.
Identity *solana.PublicKey `json:"identity,omitempty"`
}
type SlotRangeRequest struct {
@ -46,11 +51,6 @@ type SlotRangeRequest struct {
//
// This parameter is optional.
LastSlot *uint64 `json:"lastSlot,omitempty"`
// Only return results for this validator identity.
//
// This parameter is optional.
Identity *solana.PublicKey `json:"identity,omitempty"`
}
// GetBlockProduction returns recent block production information from the current or previous epoch.
@ -81,11 +81,11 @@ func (cl *Client) GetBlockProductionWithOpts(
if opts.Range.LastSlot != nil {
rngObj["lastSlot"] = opts.Range.LastSlot
}
if opts.Range.Identity != nil {
rngObj["identity"] = opts.Range.Identity
}
obj["range"] = rngObj
}
if opts.Identity != nil {
obj["identity"] = opts.Identity
}
if len(obj) != 0 {
params = append(params, obj)
}