diff --git a/src/utils/config/warpy_syncer.go b/src/utils/config/warpy_syncer.go index 608691a0..b29a1b5d 100644 --- a/src/utils/config/warpy_syncer.go +++ b/src/utils/config/warpy_syncer.go @@ -26,6 +26,9 @@ type WarpySyncer struct { // Time between poller task is called from block downloader BlockDownloaderPollerInterval int64 + // Block time + BlockDownloaderBlockTime float64 + // Warpy contract id SyncerContractId string @@ -124,6 +127,7 @@ func setWarpySyncerDefaults() { viper.SetDefault("WarpySyncer.BlockDownloaderBackoffInterval", "3s") viper.SetDefault("WarpySyncer.BlockDownloaderChannelSize", 100) viper.SetDefault("WarpySyncer.BlockDownloaderPollerInterval", 3600) + viper.SetDefault("WarpySyncer.BlockDownloaderBlockTime", float64(0.26)) viper.SetDefault("WarpySyncer.SyncerContractId", "p5OI99-BaY4QbZts266T7EDwofZqs-wVuYJmMCS0SUU") viper.SetDefault("WarpySyncer.SyncerNameServiceContractId", "p5OI99-BaY4QbZts266T7EDwofZqs-wVuYJmMCS0SUU") viper.SetDefault("WarpySyncer.SyncerChain", eth.Arbitrum) diff --git a/src/warpy_sync/block_downloader.go b/src/warpy_sync/block_downloader.go index 057d1fd4..341c042c 100644 --- a/src/warpy_sync/block_downloader.go +++ b/src/warpy_sync/block_downloader.go @@ -85,6 +85,7 @@ func (self *BlockDownloader) WithInitStartBlockHeight(db *gorm.DB, syncedCompone self.lastSyncedBlockHeight = LastSyncedBlock.FinishedBlockHeight if self.pollerCron { self.nextPollBlockHeight = self.calculateNextFullBlockHeight(self.lastSyncedBlockHeight, LastSyncedBlock.FinishedBlockTimestamp) + self.Log.WithField("block_height", self.nextPollBlockHeight).Debug("Initial full block height has been set") } return nil }) @@ -155,7 +156,7 @@ func (self *BlockDownloader) downloadBlocks(blocks []int64) (err error) { if self.pollerCron && height == nextPollBlockHeight { self.OutputPollTxs <- block.Number().Uint64() - self.nextPollBlockHeight = self.calculateNextFullBlockHeight(block.Number().Int64(), int64(block.Time())) + self.nextPollBlockHeight = block.Number().Int64() + int64(float64(self.Config.WarpySyncer.BlockDownloaderPollerInterval)/self.Config.WarpySyncer.BlockDownloaderBlockTime) self.Log.WithField("next_poll_block_height", self.nextPollBlockHeight).Debug("Next poll block height has been set") } }