-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: v2 overall stats #149
Conversation
b59c122
to
9f98680
Compare
// Check if this is the first active delegation for the staker | ||
// The order of the overall stats and staker stats update is important. | ||
// The staker stats colleciton will need to be processed first to determine if the staker is new | ||
// If the staker stats is the first delegation for the staker, we need to increment the total stakers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not 100% following this statement. why is the order matters when you have the stats_lock table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just copied this code from v1 with comments, forgot to remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var stakerStats v2dbmodel.V2StakerStatsDocument
stakerStatsFilter := bson.M{"_id": stakerPkHex}
stakerErr := stakerStatsClient.FindOne(ctx, stakerStatsFilter).Decode(&stakerStats)
if stakerErr != nil {
return nil, stakerErr
}
if stakerStats.TotalDelegations == 1 {
upsertUpdate["$inc"].(bson.M)["total_stakers"] = 1
}
checked code again so when updating overall stats, it needs to update a attribute total_stakers
which can only be computed if we query the staker stats table first
5401d51
to
5d4d257
Compare
This pr