From 5a800b1f21b67082c3815f098ebe44cf5bd3309c Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Thu, 7 Nov 2024 11:39:46 -0500 Subject: [PATCH] refactor: localstatequery client adjust GetCurrentProtocolParams to return ProtocolParameter interface (#780) Signed-off-by: Ales Verbic --- ledger/common/pparams.go | 2 +- protocol/localstatequery/client.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ledger/common/pparams.go b/ledger/common/pparams.go index 1a979921..d0c47895 100644 --- a/ledger/common/pparams.go +++ b/ledger/common/pparams.go @@ -33,7 +33,7 @@ type ProtocolParametersProtocolVersion struct { Minor uint } -type ProtocolParametersUtxorpc interface { +type ProtocolParameters interface { Utxorpc() *cardano.PParams } diff --git a/protocol/localstatequery/client.go b/protocol/localstatequery/client.go index 5efe3791..0bd565ae 100644 --- a/protocol/localstatequery/client.go +++ b/protocol/localstatequery/client.go @@ -20,6 +20,7 @@ import ( "github.com/blinklabs-io/gouroboros/cbor" "github.com/blinklabs-io/gouroboros/ledger" + ledgercommon "github.com/blinklabs-io/gouroboros/ledger/common" "github.com/blinklabs-io/gouroboros/protocol" "github.com/blinklabs-io/gouroboros/protocol/common" ) @@ -303,7 +304,7 @@ func (c *Client) GetNonMyopicMemberRewards() (*NonMyopicMemberRewardsResult, err } // GetCurrentProtocolParams returns the set of protocol params that are currently in effect -func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error) { +func (c *Client) GetCurrentProtocolParams() (ledgercommon.ProtocolParameters, error) { c.Protocol.Logger(). Debug("calling GetCurrentProtocolParams()", "component", "network", @@ -327,37 +328,37 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error) if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil case ledger.EraIdBabbage: result := []ledger.BabbageProtocolParameters{} if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil case ledger.EraIdAlonzo: result := []ledger.AlonzoProtocolParameters{} if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil case ledger.EraIdMary: result := []ledger.MaryProtocolParameters{} if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil case ledger.EraIdAllegra: result := []ledger.AllegraProtocolParameters{} if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil case ledger.EraIdShelley: result := []ledger.ShelleyProtocolParameters{} if err := c.runQuery(query, &result); err != nil { return nil, err } - return result[0], nil + return &result[0], nil default: return nil, fmt.Errorf("unknown era ID: %d", currentEra) }