Skip to content

Commit

Permalink
WarpySyncer: fix blocks interval in block downlaoder
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaziola committed Apr 16, 2024
1 parent 00eea5a commit e53cf49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/utils/config/warpy_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/warpy_sync/block_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -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")
}
}
Expand Down

0 comments on commit e53cf49

Please sign in to comment.