-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
64 lines (55 loc) · 1.32 KB
/
options.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
56
57
58
59
60
61
62
63
64
/*
Copyright (C) CESS. All rights reserved.
Copyright (C) Cumulus Encrypted Storage System. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/
package p2pgo
// ListenPort configuration listening port
func ListenPort(port int) Option {
return func(cfg *Config) error {
cfg.ListenPort = port
return nil
}
}
// Workspace configuration working directory
func Workspace(workspace string) Option {
return func(cfg *Config) error {
cfg.Workspace = workspace
return nil
}
}
// BootPeers configuration bootstrap nodes
func BootPeers(bootpeers []string) Option {
return func(cfg *Config) error {
cfg.BootPeers = bootpeers
return nil
}
}
// PrivatekeyFile configuration privatekey file
func PrivatekeyFile(privatekey string) Option {
return func(cfg *Config) error {
cfg.PrivatekeyPath = privatekey
return nil
}
}
// set protocol prefix
func ProtocolPrefix(protocolPrefix string) Option {
return func(cfg *Config) error {
cfg.ProtocolPrefix = protocolPrefix
return nil
}
}
// set timeout for dialing
func DialTimeout(timeout int) Option {
return func(cfg *Config) error {
cfg.DialTimeout = timeout
return nil
}
}
// set the boot node to record the cache channel length of other nodes
func RecordCacheLen(length int) Option {
return func(cfg *Config) error {
cfg.RecordCacheLen = length
return nil
}
}