Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
millken committed Jul 11, 2023
1 parent c0db393 commit 101224c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions blocksync/blocksync.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ func (bs *blockSyncer) flushInfo() (time.Time, uint64) {
return bs.lastTipUpdateTime, bs.targetHeight
}
func (bs *blockSyncer) syncWork() {
bs.sync()
go time.AfterFunc(bs.cfg.RateLimitInterval, func() {
bs.trigger <- struct{}{}
})
for range bs.trigger {
time.Sleep(bs.cfg.RateLimitInterval) //limit the frequency of sync
bs.sync()
Expand Down Expand Up @@ -309,7 +311,7 @@ func (bs *blockSyncer) ProcessBlock(ctx context.Context, peer string, blk *block
bs.lastTipUpdateTime = time.Now()
}
requestMaxHeight := atomic.LoadUint64(&bs.requestMaxHeight)
if syncedHeight >= requestMaxHeight && bs.IsReady() {
if requestMaxHeight > 0 && syncedHeight >= requestMaxHeight && bs.IsReady() {
bs.trigger <- struct{}{}
atomic.SwapUint64(&bs.requestMaxHeight, 0)
}
Expand Down
2 changes: 1 addition & 1 deletion blocksync/blocksync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func TestBlockSyncerBugIssue3889(t *testing.T) {
}

func TestBlockSync(t *testing.T) {
t.SkipNow()
//t.SkipNow()
require := require.New(t)
cfg := DefaultConfig
cfg.Interval = 1 * time.Second
Expand Down

0 comments on commit 101224c

Please sign in to comment.