-
Notifications
You must be signed in to change notification settings - Fork 176
/
defaults.go
32 lines (28 loc) · 1006 Bytes
/
defaults.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
31
32
package protocol
import (
"fmt"
"github.com/onflow/flow-go/model/flow"
)
// SafetyParams contains the safety parameters for the protocol related to the epochs.
// For extra details, refer to documentation of protocol.KVStoreReader.
type SafetyParams struct {
FinalizationSafetyThreshold uint64
EpochExtensionViewCount uint64
}
// DefaultEpochSafetyParams returns the default epoch safety parameters
// for each chain ID.
func DefaultEpochSafetyParams(chain flow.ChainID) (SafetyParams, error) {
switch chain {
case flow.Mainnet, flow.Testnet, flow.Sandboxnet, flow.Previewnet:
return SafetyParams{
FinalizationSafetyThreshold: 1_000,
EpochExtensionViewCount: 100_000, // approximately 1 day
}, nil
case flow.Localnet, flow.Benchnet, flow.BftTestnet, flow.Emulator:
return SafetyParams{
FinalizationSafetyThreshold: 100,
EpochExtensionViewCount: 600, // approximately 10 minutes
}, nil
}
return SafetyParams{}, fmt.Errorf("unkown chain id %s", chain.String())
}