github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/collection/epochmgr/factories/sync_core.go (about)

     1  package factories
     2  
     3  import (
     4  	"github.com/rs/zerolog"
     5  
     6  	"github.com/onflow/flow-go/model/flow"
     7  	"github.com/onflow/flow-go/module/chainsync"
     8  	"github.com/onflow/flow-go/module/metrics"
     9  )
    10  
    11  type SyncCoreFactory struct {
    12  	log  zerolog.Logger
    13  	conf chainsync.Config
    14  }
    15  
    16  func NewSyncCoreFactory(
    17  	log zerolog.Logger,
    18  	conf chainsync.Config,
    19  ) (*SyncCoreFactory, error) {
    20  	factory := &SyncCoreFactory{
    21  		log:  log,
    22  		conf: conf,
    23  	}
    24  	return factory, nil
    25  }
    26  
    27  func (f *SyncCoreFactory) Create(chainID flow.ChainID) (*chainsync.Core, error) {
    28  	core, err := chainsync.New(
    29  		f.log.With().Str("sync_chain_id", chainID.String()).Logger(),
    30  		f.conf,
    31  		metrics.NewChainSyncCollector(chainID),
    32  		chainID)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  	return core, nil
    37  }