From f1bb52822132a49b36b8a165f6b02213bbf48585 Mon Sep 17 00:00:00 2001 From: yangduo Date: Sun, 18 Aug 2024 16:23:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/marketserver/service/contribution.go | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 10b0a783..29eeacd4 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -2,8 +2,10 @@ package service import ( "f5" + "fmt" "main/constant" "q5" + "time" ) type accountContricution struct { @@ -26,6 +28,7 @@ type contribution struct { func (this *contribution) init() { this.accountContricutionlist = q5.ConcurrentMap[string, *accountContricution]{} + go this.checkContributionList() } func (this *contribution) unInit() { @@ -250,3 +253,24 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { return this.globalContribution, nil } + +func (this *contribution) checkContributionList() { + fmt.Println("checkContributionList start") + for { + if time.Now().UTC().Hour() == 0 { + nowseconds := f5.GetApp().GetRealSeconds() + deletelist := []string{} + this.accountContricutionlist.Range(func(key string, value *accountContricution) bool { + if value.gcTime+86400 < nowseconds { + deletelist = append(deletelist, key) + } + return true + }) + + for _, account := range deletelist { + this.accountContricutionlist.Delete(account) + } + } + time.Sleep((time.Second * 1800)) + } +}