-
Notifications
You must be signed in to change notification settings - Fork 178
/
sync.go
64 lines (57 loc) · 1.27 KB
/
sync.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
package factories
import (
"github.com/rs/zerolog"
syncengine "github.com/onflow/flow-go/engine/collection/synchronization"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module"
chainsync "github.com/onflow/flow-go/module/synchronization"
"github.com/onflow/flow-go/network"
"github.com/onflow/flow-go/state/cluster"
"github.com/onflow/flow-go/storage"
)
type SyncEngineFactory struct {
log zerolog.Logger
net module.Network
me module.Local
metrics module.EngineMetrics
conf chainsync.Config
}
func NewSyncEngineFactory(
log zerolog.Logger,
metrics module.EngineMetrics,
net module.Network,
me module.Local,
conf chainsync.Config,
) (*SyncEngineFactory, error) {
factory := &SyncEngineFactory{
log: log,
me: me,
net: net,
metrics: metrics,
conf: conf,
}
return factory, nil
}
func (f *SyncEngineFactory) Create(
participants flow.IdentityList,
state cluster.State,
blocks storage.ClusterBlocks,
comp network.Engine,
) (*chainsync.Core, *syncengine.Engine, error) {
core, err := chainsync.New(f.log, f.conf)
if err != nil {
return nil, nil, err
}
engine, err := syncengine.New(
f.log,
f.metrics,
f.net,
f.me,
participants,
state,
blocks,
comp,
core,
)
return core, engine, err
}