-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmoduleconfig.go
147 lines (134 loc) · 4.25 KB
/
moduleconfig.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
141
142
143
144
145
146
147
package trantor
import (
"github.com/filecoin-project/mir/pkg/availability/batchdb/fakebatchdb"
"github.com/filecoin-project/mir/pkg/availability/multisigcollector"
"github.com/filecoin-project/mir/pkg/batchfetcher"
"github.com/filecoin-project/mir/pkg/checkpoint"
"github.com/filecoin-project/mir/pkg/checkpoint/chkpvalidator"
"github.com/filecoin-project/mir/pkg/iss"
"github.com/filecoin-project/mir/pkg/mempool/simplemempool"
ordererscommon "github.com/filecoin-project/mir/pkg/orderers/common"
"github.com/filecoin-project/mir/pkg/orderers/common/pprepvalidator"
t "github.com/filecoin-project/mir/stdtypes"
)
type ModuleConfig struct {
App t.ModuleID
Availability t.ModuleID
BatchDB t.ModuleID
BatchFetcher t.ModuleID
Checkpointing t.ModuleID
ChkpValidator t.ModuleID
Crypto t.ModuleID
Hasher t.ModuleID
ISS t.ModuleID // TODO: Rename this when Trantor is generalized to use other high-level protocols
Mempool t.ModuleID
Net t.ModuleID
Null t.ModuleID
Ordering t.ModuleID
PPrepValidator t.ModuleID
PPrepValidatorChkp t.ModuleID
Timer t.ModuleID
}
func DefaultModuleConfig() ModuleConfig {
return ModuleConfig{
App: "app",
Availability: "availability",
BatchDB: "batchdb",
BatchFetcher: "batchfetcher",
Checkpointing: "checkpoint",
ChkpValidator: "chkpvalidator",
Crypto: "crypto",
Hasher: "hasher",
ISS: "iss",
Mempool: "mempool",
Net: "net",
Null: "null",
Ordering: "ordering",
PPrepValidator: "pprepvalidator",
PPrepValidatorChkp: "pprepvalidatorchkp",
Timer: "timer",
}
}
func (mc ModuleConfig) ConfigureISS() iss.ModuleConfig {
return iss.ModuleConfig{
Self: mc.ISS,
App: mc.BatchFetcher,
Availability: mc.Availability,
BatchDB: mc.BatchDB,
Checkpoint: mc.Checkpointing,
ChkpValidator: mc.ChkpValidator,
Net: mc.Net,
Ordering: mc.Ordering,
PPrepValidator: mc.PPrepValidator,
PPrepValidatorChkp: mc.PPrepValidatorChkp,
Timer: mc.Timer,
}
}
func (mc ModuleConfig) ConfigureCheckpointing() checkpoint.ModuleConfig {
return checkpoint.ModuleConfig{
Self: mc.Checkpointing,
App: mc.BatchFetcher,
Crypto: mc.Crypto,
Hasher: mc.Hasher,
Net: mc.Net,
Ord: mc.ISS,
}
}
func (mc ModuleConfig) ConfigureChkpValidator() chkpvalidator.ModuleConfig {
return chkpvalidator.ModuleConfig{
Self: mc.ChkpValidator,
}
}
func (mc ModuleConfig) ConfigureOrdering() ordererscommon.ModuleConfig {
return ordererscommon.ModuleConfig{
Self: mc.Ordering,
App: mc.BatchFetcher,
Ava: "", // Ava not initialized yet. It will be set at sub-module instantiation within the factory.
Crypto: mc.Crypto,
Hasher: mc.Hasher,
Net: mc.Net,
Ord: mc.ISS,
PPrepValidator: mc.PPrepValidator,
Timer: mc.Timer,
}
}
func (mc ModuleConfig) ConfigurePreprepareValidator() pprepvalidator.ModuleConfig {
return pprepvalidator.ModuleConfig{
Self: mc.PPrepValidator,
}
}
func (mc ModuleConfig) ConfigurePreprepareValidatorChkp() pprepvalidator.ModuleConfig {
return pprepvalidator.ModuleConfig{
Self: mc.PPrepValidatorChkp,
}
}
func (mc ModuleConfig) ConfigureSimpleMempool() simplemempool.ModuleConfig {
return simplemempool.ModuleConfig{
Self: mc.Mempool,
Hasher: mc.Hasher,
Timer: mc.Timer,
}
}
func (mc ModuleConfig) ConfigureFakeBatchDB() fakebatchdb.ModuleConfig {
return fakebatchdb.ModuleConfig{
Self: mc.BatchDB,
}
}
func (mc ModuleConfig) ConfigureMultisigCollector() multisigcollector.ModuleConfig {
return multisigcollector.ModuleConfig{
Self: mc.Availability,
Mempool: mc.Mempool,
BatchDB: mc.BatchDB,
Net: mc.Net,
Crypto: mc.Crypto,
}
}
func (mc ModuleConfig) ConfigureBatchFetcher() batchfetcher.ModuleConfig {
return batchfetcher.ModuleConfig{
Self: mc.BatchFetcher,
Availability: mc.Availability,
Checkpoint: mc.Checkpointing,
Destination: mc.App,
Mempool: mc.Mempool,
}
}