diff --git a/statefulsyncer/configuration.go b/statefulsyncer/configuration.go index de1e37a04..0b7088372 100644 --- a/statefulsyncer/configuration.go +++ b/statefulsyncer/configuration.go @@ -16,6 +16,8 @@ package statefulsyncer import ( "time" + + "github.com/coinbase/rosetta-sdk-go/syncer" ) // Option is used to overwrite default values in @@ -66,3 +68,9 @@ func WithSeenConcurrency(concurrency int64) Option { s.seenSemaphoreSize = concurrency } } + +func WithExtraSyncerOpts(os ...syncer.Option) Option { + return func(s *StatefulSyncer) { + s.extraSyncerOpts = os + } +} diff --git a/statefulsyncer/stateful_syncer.go b/statefulsyncer/stateful_syncer.go index 9056645c7..c22bdc407 100644 --- a/statefulsyncer/stateful_syncer.go +++ b/statefulsyncer/stateful_syncer.go @@ -72,6 +72,8 @@ type StatefulSyncer struct { // BlockSeen occur concurrently. seenSemaphore *semaphore.Weighted seenSemaphoreSize int64 + + extraSyncerOpts []syncer.Option } // Logger is used by the statefulsyncer to @@ -162,10 +164,12 @@ func (s *StatefulSyncer) Sync(ctx context.Context, startIndex int64, endIndex in s, s, s.cancel, - syncer.WithPastBlocks(pastBlocks), - syncer.WithCacheSize(s.cacheSize), - syncer.WithMaxConcurrency(s.maxConcurrency), - syncer.WithAdjustmentWindow(s.adjustmentWindow), + append([]syncer.Option{ + syncer.WithPastBlocks(pastBlocks), + syncer.WithCacheSize(s.cacheSize), + syncer.WithMaxConcurrency(s.maxConcurrency), + syncer.WithAdjustmentWindow(s.adjustmentWindow), + }, s.extraSyncerOpts...)..., ) return syncer.Sync(ctx, startIndex, endIndex) diff --git a/syncer/configuration.go b/syncer/configuration.go index cd63664cc..7d4f24e80 100644 --- a/syncer/configuration.go +++ b/syncer/configuration.go @@ -65,3 +65,9 @@ func WithAdjustmentWindow(adjustmentWindow int64) Option { s.adjustmentWindow = adjustmentWindow } } + +func WithCustomHelper(h func(Helper) Helper) Option { + return func(s *Syncer) { + s.helper = h(s.helper) + } +}