forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
parameters.go
30 lines (25 loc) · 924 Bytes
/
parameters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avalanche
import (
"fmt"
"github.com/MetalBlockchain/metalgo/snow/consensus/snowball"
)
// Parameters the avalanche parameters include the snowball parameters and the
// optimal number of parents
type Parameters struct {
snowball.Parameters
Parents int `json:"parents" yaml:"parents"`
BatchSize int `json:"batchSize" yaml:"batchSize"`
}
// Valid returns nil if the parameters describe a valid initialization.
func (p Parameters) Valid() error {
switch {
case p.Parents <= 1:
return fmt.Errorf("%w: parents = %d: Fails the condition that: 1 < Parents", snowball.ErrParametersInvalid, p.Parents)
case p.BatchSize <= 0:
return fmt.Errorf("%w: batchSize = %d: Fails the condition that: 0 < BatchSize", snowball.ErrParametersInvalid, p.BatchSize)
default:
return p.Parameters.Verify()
}
}