This commit is contained in:
yangduo 2024-08-18 16:23:33 +08:00
parent 0b8f8f3961
commit f1bb528221

View File

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