Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ExampleConfigs = map[string]Parameters{ "high-throughput": HighThroughputParams, "high-security": HighSecurityParams, "mobile": MobileNetworkParams, "subnet": SubnetParams, "geo-distributed": GeographicallyDistributedParams, }
ExampleConfigs provides a map of example configurations
var GeographicallyDistributedParams = Parameters{ K: 15, AlphaPreference: 10, AlphaConfidence: 12, Beta: 10, ConcurrentRepolls: 8, OptimalProcessing: 10, MaxOutstandingItems: 512, MaxItemProcessingTime: 15 * time.Second, MinRoundInterval: 400 * time.Millisecond, }
GeographicallyDistributedParams for validators spread across continents Accounts for high latency between regions
var HighSecurityParams = Parameters{ K: 31, AlphaPreference: 21, AlphaConfidence: 26, Beta: 15, ConcurrentRepolls: 4, OptimalProcessing: 5, MaxOutstandingItems: 128, MaxItemProcessingTime: 30 * time.Second, MinRoundInterval: 500 * time.Millisecond, }
HighSecurityParams optimized for maximum Byzantine fault tolerance Suitable for adversarial environments with potential attacks
var HighThroughputParams = Parameters{ K: 7, AlphaPreference: 5, AlphaConfidence: 6, Beta: 3, ConcurrentRepolls: 64, OptimalProcessing: 64, MaxOutstandingItems: 1024, MaxItemProcessingTime: 2 * time.Second, MinRoundInterval: 5 * time.Millisecond, }
HighThroughputParams optimized for maximum throughput with lower fault tolerance Suitable for permissioned networks or high-trust environments
var LocalParams = Parameters{ K: 5, AlphaPreference: 4, AlphaConfidence: 4, Beta: 3, ConcurrentRepolls: 3, OptimalProcessing: 32, MaxOutstandingItems: 256, MaxItemProcessingTime: 3690 * time.Millisecond, MinRoundInterval: 10 * time.Millisecond, }
LocalParams defines consensus parameters for local networks (5 validators). Optimized for 10 Gbps network with minimal latency.
var MainnetParams = Parameters{ K: 21, AlphaPreference: 13, AlphaConfidence: 18, Beta: 8, ConcurrentRepolls: 8, OptimalProcessing: 10, MaxOutstandingItems: 369, MaxItemProcessingTime: 9630 * time.Millisecond, MinRoundInterval: 200 * time.Millisecond, }
MainnetParams defines consensus parameters for the mainnet (21 validators). Optimized for production deployment with higher fault tolerance.
var MobileNetworkParams = Parameters{ K: 9, AlphaPreference: 6, AlphaConfidence: 7, Beta: 12, ConcurrentRepolls: 6, OptimalProcessing: 8, MaxOutstandingItems: 64, MaxItemProcessingTime: 20 * time.Second, MinRoundInterval: 300 * time.Millisecond, }
MobileNetworkParams optimized for mobile/edge devices with variable connectivity Suitable for IoT or mobile validator networks
var SubnetParams = Parameters{ K: 7, AlphaPreference: 5, AlphaConfidence: 6, Beta: 6, ConcurrentRepolls: 12, OptimalProcessing: 16, MaxOutstandingItems: 256, MaxItemProcessingTime: 5 * time.Second, MinRoundInterval: 50 * time.Millisecond, }
SubnetParams optimized for subnet/shard consensus with smaller validator sets Suitable for application-specific subnets
var TestnetParams = Parameters{ K: 11, AlphaPreference: 8, AlphaConfidence: 9, Beta: 10, ConcurrentRepolls: 10, OptimalProcessing: 10, MaxOutstandingItems: 256, MaxItemProcessingTime: 6930 * time.Millisecond, MinRoundInterval: 100 * time.Millisecond, }
TestnetParams defines consensus parameters for the testnet (11 validators). Balanced between performance and fault tolerance for testing.
Functions ¶
func Initialize ¶
func Initialize(network string)
Initialize sets the runtime parameters based on network name
func LoadFromFile ¶
LoadFromFile loads consensus parameters from a JSON file
func Override ¶
Override updates specific runtime parameters This allows consensus tools to modify parameters at runtime
func Reset ¶
func Reset(network string)
Reset resets runtime parameters to defaults for the given network
func SaveToFile ¶
SaveToFile saves the current runtime parameters to a JSON file
Types ¶
type Parameters ¶
type Parameters struct {
// K is the number of nodes to poll
K int
// AlphaPreference is the vote threshold to change preference
AlphaPreference int
// AlphaConfidence is the vote threshold for confidence
AlphaConfidence int
// Beta is the number of consecutive successful polls required for finalization
Beta int
// ConcurrentRepolls is the number of concurrent polls
ConcurrentRepolls int
// OptimalProcessing is the number of blocks to process optimally
OptimalProcessing int
// MaxOutstandingItems is the maximum number of outstanding items
MaxOutstandingItems int
// MaxItemProcessingTime is the maximum time to process an item
MaxItemProcessingTime time.Duration
// MinRoundInterval is the minimum time between rounds
MinRoundInterval time.Duration
}
Parameters defines the consensus parameters
var ( // RuntimeParams holds the current runtime consensus parameters RuntimeParams Parameters )
func GetExample ¶
func GetExample(name string) (Parameters, bool)
GetExample returns an example configuration by name
func GetParams ¶
func GetParams(network string) Parameters
GetParams returns the appropriate parameters for the given network name.
func (Parameters) Valid ¶
func (p Parameters) Valid() error
Valid returns an error if the parameters are invalid