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)) + } +}