Skip to content

Commit

Permalink
refactor: localstatequery client adjust GetCurrentProtocolParams to r…
Browse files Browse the repository at this point in the history
…eturn ProtocolParameter interface (#780)

Signed-off-by: Ales Verbic <[email protected]>
  • Loading branch information
verbotenj authored Nov 7, 2024
1 parent 0abe11b commit 5a800b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ledger/common/pparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ProtocolParametersProtocolVersion struct {
Minor uint
}

type ProtocolParametersUtxorpc interface {
type ProtocolParameters interface {
Utxorpc() *cardano.PParams
}

Expand Down
15 changes: 8 additions & 7 deletions protocol/localstatequery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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",
Expand All @@ -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)
}
Expand Down

0 comments on commit 5a800b1

Please sign in to comment.