-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coordinator): clean up challenge (#946)
Co-authored-by: georgehao <georgehao@users.noreply.github.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
- Loading branch information
1 parent
2a54c8a
commit a79992e
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cron | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/scroll-tech/go-ethereum/log" | ||
|
||
"scroll-tech/common/utils" | ||
) | ||
|
||
func (c *Collector) cleanupChallenge() { | ||
defer func() { | ||
if err := recover(); err != nil { | ||
nerr := fmt.Errorf("clean challenge panic error:%v", err) | ||
log.Warn(nerr.Error()) | ||
} | ||
}() | ||
|
||
ticker := time.NewTicker(time.Minute * 10) | ||
for { | ||
select { | ||
case <-ticker.C: | ||
expiredTime := utils.NowUTC().Add(time.Hour) | ||
if err := c.challenge.DeleteExpireChallenge(c.ctx, expiredTime); err != nil { | ||
log.Error("delete expired challenge failure", "error", err) | ||
} | ||
case <-c.ctx.Done(): | ||
if c.ctx.Err() != nil { | ||
log.Error("manager context canceled with error", "error", c.ctx.Err()) | ||
} | ||
return | ||
case <-c.stopTimeoutChan: | ||
log.Info("the coordinator run loop exit") | ||
return | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters