-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
55 lines (49 loc) · 1.3 KB
/
config.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Copyright Rockontrol Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package rksync
import (
"time"
"github.com/pkg/errors"
"github.com/rkcloudchain/rksync/config"
)
func validateGossipConfig(cfg *config.GossipConfig) error {
if len(cfg.BootstrapPeers) == 0 {
return errors.New("At least one bootstrap peer needs to be provided")
}
if cfg.Endpoint == "" {
return errors.New("Must specify the endpoint address of the peer")
}
if cfg.FileSystem == nil {
return errors.New("Must specify the FileSystem interface")
}
if cfg.PropagateIterations == 0 {
cfg.PropagateIterations = 1
}
if cfg.PropagatePeerNum == 0 {
cfg.PropagatePeerNum = 3
}
if cfg.MaxPropagationBurstSize == 0 {
cfg.MaxPropagationBurstSize = 10
}
if cfg.MaxPropagationBurstLatency == time.Duration(0) {
cfg.MaxPropagationBurstLatency = 10 * time.Millisecond
}
if cfg.PullInterval == time.Duration(0) {
cfg.PullInterval = 4 * time.Second
}
if cfg.PullPeerNum == 0 {
cfg.PullPeerNum = 3
}
if cfg.PublishCertPeriod == time.Duration(0) {
cfg.PublishCertPeriod = 20 * time.Second
}
if cfg.PublishStateInfoInterval == time.Duration(0) {
cfg.PublishStateInfoInterval = 4 * time.Second
}
if cfg.RequestStateInfoInterval == time.Duration(0) {
cfg.RequestStateInfoInterval = 4 * time.Second
}
return nil
}