Skip to content
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

Enabled clear state. Removed some extra flags. #68

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions miner/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ const (
startRecalculationsFrom = "2023-11-20T14:00:00"
timeLayout = "2006-01-02T15:04:05"

balanceForTMinusBugfixEnabled = true
balanceForTMinusBugfixEnabled = false
balanceForTMinusBugfixDryRunEnabled = true

balanceT2BugfixDryRunEnabled = false
balanceT2BugfixEnabled = false
balanceT2BugfixEnabled = true

clearBugfixDebugInfoEnabled = false
clearBugfixDebugInfoEnabled = true
)

// .
Expand Down
34 changes: 17 additions & 17 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
if _, ok := dryRunUsers[usr.ID]; !ok && usr.IDTMinus1 != 0 {
userInitialBalanceKeys = append(userInitialBalanceKeys, fmt.Sprint(usr.ID))
clickhouseKeysMap[fmt.Sprint(usr.ID)] = struct{}{}
idTminus1Key := usr.IDTMinus1
if idTminus1Key < 0 {
idTminus1Key *= -1
}
clickhouseKeysMap[fmt.Sprint(idTminus1Key)] = struct{}{}
}
}
}
Expand All @@ -313,6 +318,11 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
if _, ok := recalculatedUsers[usr.ID]; !ok && usr.IDTMinus1 != 0 {
userInitialBalanceKeys = append(userInitialBalanceKeys, fmt.Sprint(usr.ID))
clickhouseKeysMap[fmt.Sprint(usr.ID)] = struct{}{}
idTminus1Key := usr.IDTMinus1
if idTminus1Key < 0 {
idTminus1Key *= -1
}
clickhouseKeysMap[fmt.Sprint(idTminus1Key)] = struct{}{}
}
}
}
Expand All @@ -339,30 +349,20 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
if usr.IDT0 < 0 {
t0Referrals[-usr.IDT0] = nil
}
idTMinus1Key := usr.IDTMinus1
if usr.IDTMinus1 > 0 {
tMinus1Referrals[usr.IDTMinus1] = nil
}
if usr.IDTMinus1 < 0 {
tMinus1Referrals[-usr.IDTMinus1] = nil
idTMinus1Key *= -1
}
if balanceForTMinusBugfixEnabled {
if balanceForTMinusBugfixDryRunEnabled {
if _, ok := dryRunUsers[usr.ID]; !ok {
clickhouseKeysMap[fmt.Sprint(idTMinus1Key)] = struct{}{}
}
} else {
if _, ok := recalculatedUsers[usr.ID]; !ok {
clickhouseKeysMap[fmt.Sprint(idTMinus1Key)] = struct{}{}
}
}
}
}
for idT0 := range t0Referrals {
referralKeys = append(referralKeys, model.SerializedUsersKey(idT0))
}
if balanceForTMinusBugfixEnabled || balanceForTMinusBugfixDryRunEnabled {
for idTMinus1 := range tMinus1Referrals {
referralKeys = append(referralKeys, model.SerializedUsersKey(idTMinus1))
}
if balanceForTMinusBugfixEnabled {
var err error
if len(clickhouseKeysMap) > 0 {
var clickhouseKeys []string
Expand All @@ -383,7 +383,7 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
}
reqCancel()
}
if (balanceT2BugfixEnabled || balanceT2BugfixDryRunEnabled) && !balanceForTMinusBugfixEnabled {
if balanceT2BugfixEnabled && !balanceForTMinusBugfixEnabled {
var err error
reqCtx, reqCancel = context.WithTimeout(context.Background(), requestDeadline)
referralsCollection, t2Referrals, err = m.gatherReferralsInformation(reqCtx, userResults)
Expand Down Expand Up @@ -484,7 +484,7 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
}
}
}
if (balanceT2BugfixEnabled || balanceT2BugfixDryRunEnabled) && !balanceForTMinusBugfixEnabled {
if balanceT2BugfixEnabled && !balanceForTMinusBugfixEnabled {
balanceT2 := 0.0
if referralsT2, ok := t2Referrals[usr.UserID]; ok {
for _, ref := range referralsT2 {
Expand Down Expand Up @@ -744,7 +744,7 @@ func (m *miner) mine(ctx context.Context, workerNumber int64) {
log.Error(err, fmt.Sprintf("can't insert balance tminus1 recalculation dry run information for users:%#v, workerNumber:%v", userResults, workerNumber))
}
}
if balanceT2BugfixDryRunEnabled {
if balanceT2BugfixEnabled {
if err := m.insertBalanceT2RecalculationDryRunBatch(ctx, balanceT2RecalculationDryRunItems); err != nil {
log.Error(err, fmt.Sprintf("can't insert balance t2 recalculation dry run information for users:%#v, workerNumber:%v", userResults, workerNumber))
}
Expand Down
Loading