-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.go
74 lines (63 loc) · 1.51 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
65
66
67
68
69
70
71
72
73
74
/*
Copyright (C) CESS. All rights reserved.
Copyright (C) Cumulus Encrypted Storage System. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/
package sdkgo
import (
"time"
"github.com/CESSProject/cess-go-sdk/core/pattern"
)
// ConnectRpcAddrs configuration rpc address
func ConnectRpcAddrs(s []string) Option {
return func(cfg *Config) error {
cfg.Rpc = s
return nil
}
}
// Mnemonic configures the mnemonic of the signature account
func Mnemonic(mnemonic string) Option {
return func(cfg *Config) error {
cfg.Mnemonic = mnemonic
return nil
}
}
// TransactionTimeout configures the waiting timeout for a transaction
func TransactionTimeout(timeout time.Duration) Option {
return func(cfg *Config) error {
if timeout < pattern.BlockInterval {
cfg.Timeout = pattern.BlockInterval
} else {
cfg.Timeout = timeout
}
return nil
}
}
// Workspace configuration working directory
func Workspace(workspace string) Option {
return func(cfg *Config) error {
cfg.Workspace = workspace
return nil
}
}
// P2pPort configuration p2p communication port
func P2pPort(port int) Option {
return func(cfg *Config) error {
cfg.P2pPort = port
return nil
}
}
// P2pPort configuration boot node list
func Bootnodes(bootnodes []string) Option {
return func(cfg *Config) error {
cfg.Bootnodes = bootnodes
return nil
}
}
// P2pPort configuration boot node list
func ProtocolPrefix(protocolPrefix string) Option {
return func(cfg *Config) error {
cfg.ProtocolPrefix = protocolPrefix
return nil
}
}