forked from gatechain/gate-zk-smt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
49 lines (40 loc) · 984 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
package zk_smt
import (
"github.com/gatechain/gate-zk-smt/metrics"
"github.com/panjf2000/ants/v2"
)
// Option is a function that configures SMT.
type Option func(*GateSparseMerkleTree)
func InitializeVersion(version Version) Option {
return func(smt *GateSparseMerkleTree) {
smt.version = version
}
}
func BatchSizeLimit(limit int) Option {
return func(smt *GateSparseMerkleTree) {
smt.batchSizeLimit = limit
}
}
func DBCacheSize(size int) Option {
return func(smt *GateSparseMerkleTree) {
smt.dbCacheSize = size
}
}
func GoRoutinePool(pool *ants.Pool) Option {
return func(smt *GateSparseMerkleTree) {
smt.goroutinePool = pool
}
}
func GCThreshold(threshold uint64) Option {
return func(smt *GateSparseMerkleTree) {
if smt.gcStatus != nil {
smt.gcStatus.threshold = threshold
smt.gcStatus.segment = threshold / 10
}
}
}
func EnableMetrics(metrics metrics.Metrics) Option {
return func(smt *GateSparseMerkleTree) {
smt.metrics = metrics
}
}