Skip to content

Commit

Permalink
Enabled clear state. Removed some extra flags. (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-myles authored Dec 19, 2023
1 parent 24a1fc4 commit 8a58270
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
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

0 comments on commit 8a58270

Please sign in to comment.