-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
58 lines (50 loc) · 981 Bytes
/
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
// Package packer
//
// @author: xwc1125
package packer
import (
"fmt"
"github.com/chain5j/chain5j-protocol/protocol"
)
type option func(f *packer) error
func apply(f *packer, opts ...option) error {
for _, opt := range opts {
if opt == nil {
continue
}
if err := opt(f); err != nil {
return fmt.Errorf("option apply err:%v", err)
}
}
return nil
}
func WithApps(apps protocol.Apps) option {
return func(f *packer) error {
f.apps = apps
return nil
}
}
func WithConfig(config protocol.Config) option {
return func(f *packer) error {
f.config = config
return nil
}
}
func WithBlockRW(blockRW protocol.BlockReadWriter) option {
return func(f *packer) error {
f.blockRW = blockRW
return nil
}
}
func WithEngine(engine protocol.Consensus) option {
return func(f *packer) error {
f.engine = engine
return nil
}
}
func WithTxPools(txPools protocol.TxPools) option {
return func(f *packer) error {
f.txPools = txPools
return nil
}
}