Update SecondsSinceLastBlock on PPLNS scan
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
de93354347
commit
49199bf61c
|
@ -181,6 +181,8 @@ func main() {
|
|||
|
||||
var pplnsWeight types.Difficulty
|
||||
|
||||
var errord bool
|
||||
|
||||
for ps := range index.IterateSideBlocksInPPLNSWindow(tip, consensus, indexDb.GetDifficultyByHeight, indexDb.GetTipSideBlockByTemplateId, indexDb.GetSideBlocksByUncleOfId, func(b *index.SideBlock, weight types.Difficulty) {
|
||||
miners[indexDb.GetMiner(b.Miner).Id()]++
|
||||
pplnsWeight = pplnsWeight.Add(weight)
|
||||
|
@ -200,12 +202,23 @@ func main() {
|
|||
})
|
||||
}
|
||||
}, func(err error) {
|
||||
log.Panicf("error scanning PPLNS window: %s", err)
|
||||
log.Printf("error scanning PPLNS window: %s", err)
|
||||
errord = true
|
||||
}) {
|
||||
blockCount++
|
||||
uncleCount += len(ps.Uncles)
|
||||
}
|
||||
|
||||
if errord {
|
||||
if oldPoolInfo != nil {
|
||||
// got error, just update last pool
|
||||
|
||||
//this race is ok
|
||||
oldPoolInfo.SideChain.SecondsSinceLastBlock = utils.Max(0, time.Now().Unix()-int64(tip.Timestamp))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
slices.SortFunc(versions, func(a, b utils2.SideChainVersionEntry) bool {
|
||||
return a.Weight.Cmp(b.Weight) > 0
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue