github.com/koko1123/flow-go-1@v0.29.6/engine/collection/epochmgr/factories/sync.go (about) 1 package factories 2 3 import ( 4 "github.com/rs/zerolog" 5 6 syncengine "github.com/koko1123/flow-go-1/engine/collection/synchronization" 7 "github.com/koko1123/flow-go-1/model/flow" 8 "github.com/koko1123/flow-go-1/module" 9 chainsync "github.com/koko1123/flow-go-1/module/chainsync" 10 "github.com/koko1123/flow-go-1/module/metrics" 11 "github.com/koko1123/flow-go-1/network" 12 "github.com/koko1123/flow-go-1/state/cluster" 13 "github.com/koko1123/flow-go-1/storage" 14 ) 15 16 type SyncEngineFactory struct { 17 log zerolog.Logger 18 net network.Network 19 me module.Local 20 metrics module.EngineMetrics 21 conf chainsync.Config 22 } 23 24 func NewSyncEngineFactory( 25 log zerolog.Logger, 26 metrics module.EngineMetrics, 27 net network.Network, 28 me module.Local, 29 conf chainsync.Config, 30 ) (*SyncEngineFactory, error) { 31 32 factory := &SyncEngineFactory{ 33 log: log, 34 me: me, 35 net: net, 36 metrics: metrics, 37 conf: conf, 38 } 39 return factory, nil 40 } 41 42 func (f *SyncEngineFactory) Create( 43 participants flow.IdentityList, 44 state cluster.State, 45 blocks storage.ClusterBlocks, 46 comp network.Engine, 47 ) (*chainsync.Core, *syncengine.Engine, error) { 48 49 core, err := chainsync.New(f.log, f.conf, metrics.NewChainSyncCollector()) 50 if err != nil { 51 return nil, nil, err 52 } 53 engine, err := syncengine.New( 54 f.log, 55 f.metrics, 56 f.net, 57 f.me, 58 participants, 59 state, 60 blocks, 61 comp, 62 core, 63 ) 64 return core, engine, err 65 }