gecko/snow/consensus/avalanche/parameters.go

30 lines
759 B
Go

// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avalanche
import (
"fmt"
"github.com/ava-labs/gecko/snow/consensus/snowball"
)
// Parameters the avalanche paramaters include the snowball paramters and the
// optimal number of parents
type Parameters struct {
snowball.Parameters
Parents, BatchSize int
}
// Valid returns nil if the parameters describe a valid initialization.
func (p Parameters) Valid() error {
switch {
case p.Parents <= 1:
return fmt.Errorf("parents = %d: Fails the condition that: 1 < Parents", p.Parents)
case p.BatchSize <= 0:
return fmt.Errorf("batchSize = %d: Fails the condition that: 0 < BatchSize", p.BatchSize)
default:
return p.Parameters.Valid()
}
}