-
Notifications
You must be signed in to change notification settings - Fork 175
/
hub.go
58 lines (53 loc) · 1.36 KB
/
hub.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 factories
import (
"github.com/rs/zerolog"
"github.com/onflow/flow-go/consensus"
"github.com/onflow/flow-go/engine/collection"
"github.com/onflow/flow-go/engine/collection/message_hub"
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/network"
"github.com/onflow/flow-go/state/cluster"
"github.com/onflow/flow-go/state/protocol"
"github.com/onflow/flow-go/storage"
)
type MessageHubFactory struct {
log zerolog.Logger
me module.Local
net network.Network
protoState protocol.State
engineMetrics module.EngineMetrics
}
func NewMessageHubFactory(log zerolog.Logger,
net network.Network,
me module.Local,
engineMetrics module.EngineMetrics,
protoState protocol.State) *MessageHubFactory {
return &MessageHubFactory{
log: log,
me: me,
net: net,
protoState: protoState,
engineMetrics: engineMetrics,
}
}
func (f *MessageHubFactory) Create(
clusterState cluster.State,
payloads storage.ClusterPayloads,
hotstuff module.HotStuff,
compliance collection.Compliance,
hotstuffModules *consensus.HotstuffModules,
) (*message_hub.MessageHub, error) {
return message_hub.NewMessageHub(
f.log,
f.engineMetrics,
f.net,
f.me,
compliance,
hotstuff,
hotstuffModules.VoteAggregator,
hotstuffModules.TimeoutAggregator,
f.protoState,
clusterState,
payloads,
)
}