|
| 1 | +// Copyright 2025 Blink Labs Software |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package leios |
| 16 | + |
| 17 | +import ( |
| 18 | + "encoding/json" |
| 19 | + "io" |
| 20 | + "os" |
| 21 | +) |
| 22 | + |
| 23 | +type LeiosGenesis struct { |
| 24 | + HeaderDiffusionPeriod uint `json:"headerDiffusionPeriod"` |
| 25 | + VotingPeriod uint `json:"votingPeriod"` |
| 26 | + DiffusionPeriod uint `json:"diffusionPeriod"` |
| 27 | + RankingBlockMaxSize uint `json:"rankingBlockMaxSize"` |
| 28 | + EndorserBlockReferenceTxMaxSize uint `json:"endorserBlockRefTxMaxSize"` |
| 29 | + EndorserBlockMaxSize uint `json:"endorserBlockMaxSize"` |
| 30 | + MeanCommitteeSize uint `json:"meanCommitteeSize"` |
| 31 | + QuorumSize uint `json:"quorumSize"` |
| 32 | + MaxExStepPerEndorserBlock int64 `json:"maxExStepPerEndorserBlock"` |
| 33 | + MaxExMemPerEndorserBlock int64 `json:"maxExMemPerEndorserBlock"` |
| 34 | + MaxExStepPerTransaction int64 `json:"maxExStepPerTransaction"` |
| 35 | + MaxExMemPerTransaction int64 `json:"maxExMemPerTransaction"` |
| 36 | +} |
| 37 | + |
| 38 | +func NewLeiosGenesisFromReader(r io.Reader) (LeiosGenesis, error) { |
| 39 | + var ret LeiosGenesis |
| 40 | + dec := json.NewDecoder(r) |
| 41 | + dec.DisallowUnknownFields() |
| 42 | + if err := dec.Decode(&ret); err != nil { |
| 43 | + return ret, err |
| 44 | + } |
| 45 | + return ret, nil |
| 46 | +} |
| 47 | + |
| 48 | +func NewLeiosGenesisFromFile(path string) (LeiosGenesis, error) { |
| 49 | + f, err := os.Open(path) |
| 50 | + if err != nil { |
| 51 | + return LeiosGenesis{}, err |
| 52 | + } |
| 53 | + defer f.Close() |
| 54 | + return NewLeiosGenesisFromReader(f) |
| 55 | +} |
0 commit comments