-
Notifications
You must be signed in to change notification settings - Fork 0
/
ledger.go
140 lines (119 loc) · 3.77 KB
/
ledger.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Copyright 2018 Insolar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package configuration
import (
"time"
"github.com/insolar/insolar/core"
)
// Storage configures Ledger's storage.
type Storage struct {
// DataDirectory is a directory where database's files live.
DataDirectory string
// TxRetriesOnConflict defines how many retries on transaction conflicts
// storage update methods should do.
TxRetriesOnConflict int
}
// JetCoordinator holds configuration for JetCoordinator.
type JetCoordinator struct {
RoleCounts map[int]int
}
// PulseManager holds configuration for PulseManager.
type PulseManager struct {
// HeavySyncEnabled enables replication to heavy (could be disabled for testing purposes)
HeavySyncEnabled bool
// HeavySyncMessageLimit soft limit of single message for replication to heavy.
HeavySyncMessageLimit int
// Backoff configures retry backoff algorithm for Heavy Sync
HeavyBackoff Backoff
// SplitThreshold is a drop size threshold in bytes to perform split.
SplitThreshold uint64
}
// Backoff configures retry backoff algorithm
type Backoff struct {
Factor float64
//Jitter eases contention by randomizing backoff steps
Jitter bool
//Min and Max are the minimum and maximum values of the counter
Min, Max time.Duration
}
// RecentStorage holds configuration for RecentStorage
type RecentStorage struct {
// Default TTL is a value of default ttl for redirects
DefaultTTL int
}
// Exporter holds configuration of Exporter
type Exporter struct {
// ExportLag is lag in second before we start to export pulse
ExportLag uint32
}
// Ledger holds configuration for ledger.
type Ledger struct {
// Storage defines storage configuration.
Storage Storage
// JetCoordinator defines jet coordinator configuration.
JetCoordinator JetCoordinator
// PulseManager holds configuration for PulseManager.
PulseManager PulseManager
// RecentStorage holds configuration for RecentStorage
RecentStorage RecentStorage
// common/sharable values:
// LightChainLimit is maximum pulse difference (NOT number of pulses)
// between current and the latest replicated on heavy.
//
// IMPORTANT: It should be the same on ALL nodes.
LightChainLimit int
// JetSizesHistoryDepth holds maximum number of drop sizes
JetSizesHistoryDepth int
// Exporter holds configuration of Exporter
Exporter Exporter
}
// NewLedger creates new default Ledger configuration.
func NewLedger() Ledger {
return Ledger{
Storage: Storage{
DataDirectory: "./data",
TxRetriesOnConflict: 3,
},
JetCoordinator: JetCoordinator{
RoleCounts: map[int]int{
int(core.DynamicRoleVirtualExecutor): 1,
int(core.DynamicRoleHeavyExecutor): 1,
int(core.DynamicRoleLightExecutor): 1,
int(core.DynamicRoleVirtualValidator): 1,
int(core.DynamicRoleLightValidator): 1,
},
},
PulseManager: PulseManager{
HeavySyncEnabled: true,
HeavySyncMessageLimit: 1 << 20, // 1Mb
HeavyBackoff: Backoff{
Jitter: true,
Min: 200 * time.Millisecond,
Max: 2 * time.Second,
Factor: 2,
},
SplitThreshold: 10 * 100, // 10 megabytes.
},
RecentStorage: RecentStorage{
DefaultTTL: 10,
},
LightChainLimit: 5, // 5 pulses
JetSizesHistoryDepth: 10,
Exporter: Exporter{
ExportLag: 40, // 40 seconds
},
}
}