Skip to content

Commit

Permalink
removed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-ares committed Mar 27, 2023
1 parent 624f577 commit 1abf60b
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 150 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ require (
google.golang.org/api v0.114.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/appengine/v2 v2.0.2 // indirect
google.golang.org/genproto v0.0.0-20230327152035-dc694ad2151e // indirect
google.golang.org/genproto v0.0.0-20230327215041-6ac7f18bb9d5 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20230327152035-dc694ad2151e h1:rRGPYd0STm9H4Ci+iGrSLG35mkAKY41/nzCcG7PQADw=
google.golang.org/genproto v0.0.0-20230327152035-dc694ad2151e/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak=
google.golang.org/genproto v0.0.0-20230327215041-6ac7f18bb9d5 h1:Kd6tRRHXw8z4TlPlWi+NaK10gsePL6GdZBQChptOLGA=
google.golang.org/genproto v0.0.0-20230327215041-6ac7f18bb9d5/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down
12 changes: 0 additions & 12 deletions tokenomics/adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ func (r *repository) GetAdoptionSummary(ctx context.Context) (as *AdoptionSummar
if as = new(AdoptionSummary); ctx.Err() != nil {
return nil, errors.Wrap(ctx.Err(), "context failed")
}
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetAdoptionSummary took: %v", elapsed))
}
}()
key := r.totalActiveUsersGlobalParentKey(time.Now().Time)
if as.TotalActiveUsers, err = r.getGlobalUnsignedValue(ctx, key); err != nil && !errors.Is(err, storage.ErrNotFound) {
return nil, errors.Wrapf(err, "failed to get totalActiveUsers getGlobalUnsignedValue for key:%v", key)
Expand Down Expand Up @@ -182,12 +176,6 @@ func (r *repository) getNextAdoption(ctx context.Context) (*Adoption[coin.ICEFla
WHERE x.consecutive_durations == :expected_consecutive_durations
AND x.achieved_at IS NULL`, strings.Join(keyParams, ","), currentAdoptionSQL())
resp := make([]*Adoption[coin.ICEFlake], 0, 1)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]getNextAdoption SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrap(err, "failed to select if the next adoption is achieved")
}
Expand Down
18 changes: 0 additions & 18 deletions tokenomics/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ FROM (SELECT MAX(st.years) AS pre_staking_years,
PreStakingAllocation, PreStakingBonus uint64
BalanceWorkerStarted bool
}, 0, 1+1+1)
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetBalanceSummary SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrapf(err, "failed to select user's balances for user_id:%v", userID)
}
Expand Down Expand Up @@ -145,12 +139,6 @@ func (r *repository) GetBalanceHistory( //nolint:funlen,gocognit,revive,gocyclo,
AND type = %[2]v
AND type_detail in (%[3]v)`, r.workerIndex(ctx), totalNoPreStakingBonusBalanceType, strings.Join(typeDetails, ","))
res := make([]*balance, 0, 2*len(typeDetails)) //nolint:gomnd // Cuz there's a positive and a negative one.
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetBalanceHistory SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &res); err != nil {
return nil, errors.Wrapf(err, "failed to select balance history for params:%#v", params)
}
Expand Down Expand Up @@ -442,12 +430,6 @@ func (r *repository) insertOrReplaceBalances( //nolint:revive // Alot of SQL par
}
sql := fmt.Sprintf(`%v INTO balances_%v (updated_at,user_id,type,type_detail,negative,amount)
VALUES %v`, insertOrReplace, workerIndex, strings.Join(values, ","))
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]insert:%v replace balances SQL took: %v", insertOrReplace, elapsed))
}
}()
if _, err := storage.CheckSQLDMLResponse(r.db.Execute(sql)); err != nil {
return errors.Wrapf(err, "failed at %v to %v balances:%#v", updatedAt, insertOrReplace, balances)
}
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/balance_recalculation.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ func (s *balanceRecalculationTriggerStreamSource) Process(ignoredCtx context.Con
if ignoredCtx.Err() != nil {
return errors.Wrap(ignoredCtx.Err(), "unexpected deadline while processing message")
}
before2 := time.Now()
defer func() {
log.Info(fmt.Sprintf("[response]balanceRecalculationTriggerStreamSource.Process[%v] took: %v", uint64(msg.Partition), stdlibtime.Since(*before2.Time)))
}()
const deadline = 5 * stdlibtime.Minute
ctx, cancel := context.WithTimeout(context.Background(), deadline)
defer cancel()
Expand Down Expand Up @@ -206,12 +202,6 @@ FROM (SELECT COUNT(t1.user_id) AS t1,
params["previousDurationTypeDetail"] = fmt.Sprintf("/%v", now.Add(-1*s.cfg.GlobalAggregationInterval.Child).Format(s.cfg.globalAggregationIntervalChildDateFormat())) //nolint:lll // .
const estimatedBalancesPerUser = 14
resp := make([]*balanceRecalculationRow, 0, balanceRecalculationBatchSize*estimatedBalancesPerUser)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]balanceRecalculation SQL took: %v", elapsed))
}
}()
if err := s.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrapf(err, "failed to select new balance recalculation batch for workerIndex:%v,params:%#v", workerIndex, params)
}
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/blockchain_balance_synchronization.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ func (s *blockchainBalanceSynchronizationTriggerStreamSource) Process(ignoredCtx
if ignoredCtx.Err() != nil {
return errors.Wrap(ignoredCtx.Err(), "unexpected deadline while processing message")
}
before2 := time.Now()
defer func() {
log.Info(fmt.Sprintf("[response]blockchainBalanceSynchronizationTriggerStreamSource.Process[%v] took: %v", uint64(msg.Partition), stdlibtime.Since(*before2.Time)))
}()
const deadline = 5 * stdlibtime.Minute
ctx, cancel := context.WithTimeout(context.Background(), deadline)
defer cancel()
Expand Down Expand Up @@ -202,12 +198,6 @@ FROM (SELECT MAX(st.years) AS pre_staking_years,
AND b.type = %[4]v
AND b.type_detail = ''`, limit, workerIndex, totalNoPreStakingBonusBalanceType, pendingXBalanceType, strings.Join(typeDetails, ","))
res := make([]*latestBalanceSQLRow, 0, limit)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]blockchainSync SQL took: %v", elapsed))
}
}()
if err := s.db.PrepareExecuteTyped(sql, params, &res); err != nil {
return nil, errors.Wrapf(err,
"failed to select a batch of latest information about latest calculating balances for workerIndex:%v,params:%#v", workerIndex, params)
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/extra_bonus.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ func (r *repository) ClaimExtraBonus(ctx context.Context, ebs *ExtraBonusSummary
return errors.Wrap(ctx.Err(), "unexpected deadline")
}
now := time.Now()
before := time.Now()
bonus, err := r.getAvailableExtraBonus(ctx, now, ebs.UserID)
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]getAvailableExtraBonus SQL took: %v", elapsed))
}
if err != nil {
return errors.Wrapf(err, "failed to getAvailableExtraBonus for userID:%v", ebs.UserID)
}
Expand All @@ -46,12 +42,6 @@ func (r *repository) ClaimExtraBonus(ctx context.Context, ebs *ExtraBonusSummary
extra_bonus_ended_at = :now_nanos + :duration
WHERE user_id = :user_id
AND :now_nanos - IFNULL(extra_bonus_started_at,0) > :claim_window`, r.workerIndex(ctx))
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]ClaimExtraBonus SQL took: %v", elapsed))
}
}()
if err = storage.CheckSQLDMLErr(r.db.PrepareExecute(sql, params)); err != nil {
if errors.Is(err, storage.ErrNotFound) {
err = ErrDuplicate
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/extra_bonus_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ func (s *extraBonusProcessingTriggerStreamSource) Process(ignoredCtx context.Con
if ignoredCtx.Err() != nil {
return errors.Wrap(ignoredCtx.Err(), "unexpected deadline while processing message")
}
before2 := time.Now()
defer func() {
log.Info(fmt.Sprintf("[response]extraBonusProcessingTriggerStreamSource.Process[%v] took: %v", uint64(msg.Partition), stdlibtime.Since(*before2.Time)))
}()
const deadline = 5 * stdlibtime.Minute
ctx, cancel := context.WithTimeout(context.Background(), deadline)
defer cancel()
Expand Down Expand Up @@ -147,12 +143,6 @@ func (s *extraBonusProcessingTriggerStreamSource) getAvailableExtraBonuses(
UserID string
NewsSeen, FlatBonus, BonusPercentageRemaining, ExtraBonusIndex uint64
}, 0, extraBonusProcessingBatchSize)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]stream:getAvailableExtraBonuses SQL took: %v", elapsed))
}
}()
if err = s.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return 0, nil, errors.Wrapf(err, "failed to select for availableExtraBonuses for workerIndex:%v", workerIndex)
}
Expand Down
25 changes: 0 additions & 25 deletions tokenomics/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/ice-blockchain/wintr/coin"
"github.com/ice-blockchain/wintr/connectors/storage"
"github.com/ice-blockchain/wintr/log"
"github.com/ice-blockchain/wintr/time"
)

Expand Down Expand Up @@ -67,12 +66,6 @@ WHERE user_id = :user_id`, registrationICEFlakeBonusAmount)
params := make(map[string]any, 1)
params["user_id"] = userID
resp := make([]*RankingSummary, 0, 1+1)
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetRankingSummary SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrapf(err, "failed to select miner global rank for userID:%v", userID)
}
Expand All @@ -91,20 +84,8 @@ func (r *repository) GetTopMiners(ctx context.Context, keyword string, limit, of
return nil, errors.Wrap(ctx.Err(), "unexpected deadline")
}
if keyword == "" {
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetTopMiners SQL took: %v", elapsed))
}
}()
return r.getTopMiners(ctx, limit, offset)
} else { //nolint:revive // Nope.
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetTopMiners[keyword] SQL took: %v", elapsed))
}
}()
return r.getTopMinersByKeyword(ctx, keyword, limit, offset)
}
}
Expand Down Expand Up @@ -352,12 +333,6 @@ FROM (SELECT MAX(st.years) AS pre_staking_years,
BonusPercentageRemaining uint64
NewsSeen uint64
}, 0, 1)
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetMiningSummary SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrapf(err, "failed to select for mining summary for userID:%v", userID)
}
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/mining_rates_recalculation.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ func (s *miningRatesRecalculationTriggerStreamSource) Process(ignoredCtx context
if ignoredCtx.Err() != nil {
return errors.Wrap(ignoredCtx.Err(), "unexpected deadline while processing message")
}
before2 := time.Now()
defer func() {
log.Info(fmt.Sprintf("[response]miningRatesRecalculationTriggerStreamSource.Process[%v] took: %v", uint64(msg.Partition), stdlibtime.Since(*before2.Time)))
}()
const deadline = 5 * stdlibtime.Minute
ctx, cancel := context.WithTimeout(context.Background(), deadline)
defer cancel()
Expand Down Expand Up @@ -254,12 +250,6 @@ FROM (SELECT MAX(st.years) AS pre_staking_years,
params := make(map[string]any, 1)
params["now_nanos"] = now
res := make([]*latestMiningRateCalculationSQLRow, 0, miningRatesRecalculationBatchSize)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]stream:miningRates SQL took: %v", elapsed))
}
}()
if err := s.db.PrepareExecuteTyped(sql, params, &res); err != nil {
return nil, errors.Wrapf(err, "failed to select a batch of latest user mining rate calculation parameters for workerIndex:%v", workerIndex)
}
Expand Down
11 changes: 0 additions & 11 deletions tokenomics/mining_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/ice-blockchain/wintr/coin"
messagebroker "github.com/ice-blockchain/wintr/connectors/message_broker"
"github.com/ice-blockchain/wintr/log"
"github.com/ice-blockchain/wintr/terror"
"github.com/ice-blockchain/wintr/time"
)
Expand All @@ -27,11 +26,7 @@ func (r *repository) StartNewMiningSession( //nolint:funlen,gocognit // A lot of
return errors.Wrap(ctx.Err(), "unexpected deadline")
}
userID := *ms.MiningSession.UserID
before := time.Now()
old, err := r.getInternalMiningSummary(ctx, userID)
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]getInternalMiningSummary SQL took: %v", elapsed))
}
if err != nil {
return errors.Wrapf(err, "failed to getMiningSummary for userID:%v", userID)
}
Expand All @@ -47,12 +42,6 @@ func (r *repository) StartNewMiningSession( //nolint:funlen,gocognit // A lot of
return err
}
newMS := r.newMiningSummary(old, now)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]insertNewMiningSession SQL took: %v", elapsed))
}
}()
if err = r.insertNewMiningSession(ctx, userID, old, newMS, shouldRollback); err != nil {
return errors.Wrapf(err,
"failed to insertNewMiningSession:%#v,userID:%v,rollbackNegativeMiningProgress:%v", newMS, userID, shouldRollback)
Expand Down
21 changes: 0 additions & 21 deletions tokenomics/pre_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ package tokenomics
import (
"context"
"fmt"
stdlibtime "time"

"github.com/goccy/go-json"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"

"github.com/ice-blockchain/go-tarantool-client"
messagebroker "github.com/ice-blockchain/wintr/connectors/message_broker"
"github.com/ice-blockchain/wintr/connectors/storage"
"github.com/ice-blockchain/wintr/log"
"github.com/ice-blockchain/wintr/time"
)

Expand All @@ -35,12 +32,6 @@ func (r *repository) GetPreStakingSummary(ctx context.Context, userID string) (*
params := make(map[string]any, 1)
params["user_id"] = userID
resp := make([]*PreStakingSummary, 0, 1)
before := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]GetPreStakingSummary SQL took: %v", elapsed))
}
}()
if err := r.db.PrepareExecuteTyped(sql, params, &resp); err != nil {
return nil, errors.Wrapf(err, "failed to select for pre-staking summary for userID:%v", userID)
}
Expand All @@ -66,12 +57,6 @@ func (r *repository) getAllPreStakingSummaries(ctx context.Context, userID strin
ORDER BY st.created_at`, r.workerIndex(ctx))
params := make(map[string]any, 1)
params["user_id"] = userID
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]getAllPreStakingSummaries SQL took: %v", elapsed))
}
}()
err = errors.Wrapf(r.db.PrepareExecuteTyped(sql, params, &resp), "failed to select all pre-staking summaries for userID:%v", userID)

return
Expand Down Expand Up @@ -104,12 +89,6 @@ func (r *repository) StartOrUpdatePreStaking(ctx context.Context, st *PreStaking
params["user_id"] = st.UserID
params["years"] = st.Years
params["allocation"] = st.Allocation
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]StartOrUpdatePreStaking SQL took: %v", elapsed))
}
}()
if err = storage.CheckSQLDMLErr(r.db.PrepareExecute(sql, params)); err != nil {
return errors.Wrapf(err, "failed to insertNewPreStaking:%#v", st)
}
Expand Down
10 changes: 0 additions & 10 deletions tokenomics/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package tokenomics
import (
"context"
"fmt"
stdlibtime "time"

"github.com/goccy/go-json"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
Expand All @@ -16,8 +14,6 @@ import (
"github.com/ice-blockchain/wintr/coin"
messagebroker "github.com/ice-blockchain/wintr/connectors/message_broker"
"github.com/ice-blockchain/wintr/connectors/storage"
"github.com/ice-blockchain/wintr/log"
"github.com/ice-blockchain/wintr/time"
)

func (s *usersTableSource) Process(ctx context.Context, msg *messagebroker.Message) error { //nolint:gocognit // .
Expand Down Expand Up @@ -115,12 +111,6 @@ func (s *usersTableSource) removeBalanceFromT0AndTMinus1(ctx context.Context, us
T0UserID, TMinus1UserID string
}
res := make([]*resp, 0, 1)
before2 := time.Now()
defer func() {
if elapsed := stdlibtime.Since(*before2.Time); elapsed > 100*stdlibtime.Millisecond {
log.Info(fmt.Sprintf("[response]cleanup_balance_t1_t2 SQL took: %v", elapsed))
}
}()
if err := s.db.PrepareExecuteTyped(sql, params, &res); err != nil {
return errors.Wrapf(err, "failed to get reverse t0 and t-1 balance information for userID:%v", usr.ID)
}
Expand Down

0 comments on commit 1abf60b

Please sign in to comment.