Skip to content

Commit 5a800b1

Browse files
authored
refactor: localstatequery client adjust GetCurrentProtocolParams to return ProtocolParameter interface (#780)
Signed-off-by: Ales Verbic <[email protected]>
1 parent 0abe11b commit 5a800b1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

ledger/common/pparams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type ProtocolParametersProtocolVersion struct {
3333
Minor uint
3434
}
3535

36-
type ProtocolParametersUtxorpc interface {
36+
type ProtocolParameters interface {
3737
Utxorpc() *cardano.PParams
3838
}
3939

protocol/localstatequery/client.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/blinklabs-io/gouroboros/cbor"
2222
"github.com/blinklabs-io/gouroboros/ledger"
23+
ledgercommon "github.com/blinklabs-io/gouroboros/ledger/common"
2324
"github.com/blinklabs-io/gouroboros/protocol"
2425
"github.com/blinklabs-io/gouroboros/protocol/common"
2526
)
@@ -303,7 +304,7 @@ func (c *Client) GetNonMyopicMemberRewards() (*NonMyopicMemberRewardsResult, err
303304
}
304305

305306
// GetCurrentProtocolParams returns the set of protocol params that are currently in effect
306-
func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error) {
307+
func (c *Client) GetCurrentProtocolParams() (ledgercommon.ProtocolParameters, error) {
307308
c.Protocol.Logger().
308309
Debug("calling GetCurrentProtocolParams()",
309310
"component", "network",
@@ -327,37 +328,37 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
327328
if err := c.runQuery(query, &result); err != nil {
328329
return nil, err
329330
}
330-
return result[0], nil
331+
return &result[0], nil
331332
case ledger.EraIdBabbage:
332333
result := []ledger.BabbageProtocolParameters{}
333334
if err := c.runQuery(query, &result); err != nil {
334335
return nil, err
335336
}
336-
return result[0], nil
337+
return &result[0], nil
337338
case ledger.EraIdAlonzo:
338339
result := []ledger.AlonzoProtocolParameters{}
339340
if err := c.runQuery(query, &result); err != nil {
340341
return nil, err
341342
}
342-
return result[0], nil
343+
return &result[0], nil
343344
case ledger.EraIdMary:
344345
result := []ledger.MaryProtocolParameters{}
345346
if err := c.runQuery(query, &result); err != nil {
346347
return nil, err
347348
}
348-
return result[0], nil
349+
return &result[0], nil
349350
case ledger.EraIdAllegra:
350351
result := []ledger.AllegraProtocolParameters{}
351352
if err := c.runQuery(query, &result); err != nil {
352353
return nil, err
353354
}
354-
return result[0], nil
355+
return &result[0], nil
355356
case ledger.EraIdShelley:
356357
result := []ledger.ShelleyProtocolParameters{}
357358
if err := c.runQuery(query, &result); err != nil {
358359
return nil, err
359360
}
360-
return result[0], nil
361+
return &result[0], nil
361362
default:
362363
return nil, fmt.Errorf("unknown era ID: %d", currentEra)
363364
}

0 commit comments

Comments
 (0)