From 0b2aa02d184d9e716a2208652e760033fc4f29ed Mon Sep 17 00:00:00 2001 From: Ales Verbic Date: Wed, 17 Apr 2024 22:46:49 -0400 Subject: [PATCH] feat:add Allegra protocol parameters support (#588) Signed-off-by: Ales Verbic --- ledger/allegra.go | 13 +++++++++++++ protocol/localstatequery/client.go | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/ledger/allegra.go b/ledger/allegra.go index 5b5f517a..a9f0679b 100644 --- a/ledger/allegra.go +++ b/ledger/allegra.go @@ -114,6 +114,11 @@ func (h *AllegraBlockHeader) Era() Era { type AllegraTransactionBody struct { ShelleyTransactionBody + Update struct { + cbor.StructAsArray + ProtocolParamUpdates map[Blake2b224]AllegraProtocolParameterUpdate + Epoch uint64 + } `cbor:"6,keyasint,omitempty"` ValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"` } @@ -191,6 +196,14 @@ func (t *AllegraTransaction) Cbor() []byte { return cborData } +type AllegraProtocolParameters struct { + ShelleyProtocolParameters +} + +type AllegraProtocolParameterUpdate struct { + ShelleyProtocolParameterUpdate +} + func NewAllegraBlockFromCbor(data []byte) (*AllegraBlock, error) { var allegraBlock AllegraBlock if _, err := cbor.Decode(data, &allegraBlock); err != nil { diff --git a/protocol/localstatequery/client.go b/protocol/localstatequery/client.go index 603de351..8c35293b 100644 --- a/protocol/localstatequery/client.go +++ b/protocol/localstatequery/client.go @@ -354,6 +354,12 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error) return nil, err } 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 case ledger.EraIdShelley: result := []ledger.ShelleyProtocolParameters{} if err := c.runQuery(query, &result); err != nil {