|
15 | 15 | package babbage |
16 | 16 |
|
17 | 17 | import ( |
| 18 | + "fmt" |
18 | 19 | "math" |
19 | 20 |
|
20 | 21 | "github.com/blinklabs-io/gouroboros/cbor" |
@@ -162,32 +163,32 @@ func (u *BabbageProtocolParameterUpdate) UnmarshalCBOR(cborData []byte) error { |
162 | 163 | return nil |
163 | 164 | } |
164 | 165 |
|
165 | | -func (p *BabbageProtocolParameters) Utxorpc() *cardano.PParams { |
| 166 | +func (p *BabbageProtocolParameters) Utxorpc() (*cardano.PParams, error) { |
166 | 167 | // sanity check |
167 | 168 | if p.A0.Num().Int64() > math.MaxInt32 || |
168 | 169 | p.A0.Denom().Int64() < 0 || |
169 | 170 | p.A0.Denom().Int64() > math.MaxUint32 { |
170 | | - return nil |
| 171 | + return nil, fmt.Errorf("invalid A0 rational number values") |
171 | 172 | } |
172 | 173 | if p.Rho.Num().Int64() > math.MaxInt32 || |
173 | 174 | p.Rho.Denom().Int64() < 0 || |
174 | 175 | p.Rho.Denom().Int64() > math.MaxUint32 { |
175 | | - return nil |
| 176 | + return nil, fmt.Errorf("invalid Rho rational number values") |
176 | 177 | } |
177 | 178 | if p.Tau.Num().Int64() > math.MaxInt32 || |
178 | 179 | p.Tau.Denom().Int64() < 0 || |
179 | 180 | p.Tau.Denom().Int64() > math.MaxUint32 { |
180 | | - return nil |
| 181 | + return nil, fmt.Errorf("invalid Tau rational number values") |
181 | 182 | } |
182 | 183 | if p.ExecutionCosts.MemPrice.Num().Int64() > math.MaxInt32 || |
183 | 184 | p.ExecutionCosts.MemPrice.Denom().Int64() < 0 || |
184 | 185 | p.ExecutionCosts.MemPrice.Denom().Int64() > math.MaxUint32 { |
185 | | - return nil |
| 186 | + return nil, fmt.Errorf("invalid memory price rational number values") |
186 | 187 | } |
187 | 188 | if p.ExecutionCosts.StepPrice.Num().Int64() > math.MaxInt32 || |
188 | 189 | p.ExecutionCosts.StepPrice.Denom().Int64() < 0 || |
189 | 190 | p.ExecutionCosts.StepPrice.Denom().Int64() > math.MaxUint32 { |
190 | | - return nil |
| 191 | + return nil, fmt.Errorf("invalid step price rational number values") |
191 | 192 | } |
192 | 193 | // #nosec G115 |
193 | 194 | return &cardano.PParams{ |
@@ -242,7 +243,7 @@ func (p *BabbageProtocolParameters) Utxorpc() *cardano.PParams { |
242 | 243 | Memory: p.MaxBlockExUnits.Memory, |
243 | 244 | Steps: p.MaxBlockExUnits.Steps, |
244 | 245 | }, |
245 | | - } |
| 246 | + }, nil |
246 | 247 | } |
247 | 248 |
|
248 | 249 | func UpgradePParams( |
|
0 commit comments