-
Notifications
You must be signed in to change notification settings - Fork 177
/
proposal.go
69 lines (60 loc) · 1.79 KB
/
proposal.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
package factories
import (
"fmt"
"github.com/rs/zerolog"
"github.com/onflow/flow-go/engine/collection/compliance"
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/module/buffer"
"github.com/onflow/flow-go/state/cluster"
"github.com/onflow/flow-go/state/protocol"
"github.com/onflow/flow-go/storage"
)
type ProposalEngineFactory struct {
log zerolog.Logger
me module.Local
net module.Network
colMetrics module.CollectionMetrics
engMetrics module.EngineMetrics
mempoolMetrics module.MempoolMetrics
protoState protocol.State
transactions storage.Transactions
}
// NewFactory returns a new collection proposal engine factory.
func NewProposalEngineFactory(
log zerolog.Logger,
net module.Network,
me module.Local,
colMetrics module.CollectionMetrics,
engMetrics module.EngineMetrics,
mempoolMetrics module.MempoolMetrics,
protoState protocol.State,
transactions storage.Transactions,
) (*ProposalEngineFactory, error) {
factory := &ProposalEngineFactory{
log: log,
me: me,
net: net,
colMetrics: colMetrics,
engMetrics: engMetrics,
mempoolMetrics: mempoolMetrics,
protoState: protoState,
transactions: transactions,
}
return factory, nil
}
func (f *ProposalEngineFactory) Create(clusterState cluster.MutableState, headers storage.Headers, payloads storage.ClusterPayloads) (*compliance.Engine, error) {
cache := buffer.NewPendingClusterBlocks()
core, err := compliance.NewCore(f.log, f.engMetrics, f.mempoolMetrics, f.colMetrics, headers, clusterState, cache)
if err != nil {
return nil, fmt.Errorf("could create cluster compliance core: %w", err)
}
engine, err := compliance.NewEngine(
f.log,
f.net,
f.me,
f.protoState,
payloads,
core,
)
return engine, err
}