Skip to content

Commit

Permalink
lint: cleanup variable shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
IdrisHanafi committed Oct 16, 2023
1 parent f8c1b02 commit f0d0541
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,13 @@ func blockUntilSuccessful(ctx context.Context, c *ethclient.Client, f func() err
numberOfBlocksToWaitFor := *inputLoadTestParams.ContractCallNumberOfBlocksToWaitFor
blockInterval := *inputLoadTestParams.ContractCallBlockInterval
start := time.Now()
startBlockNumber, err := c.BlockNumber(ctx)
currStartBlockNumber, err := c.BlockNumber(ctx)
if err != nil {
log.Error().Err(err).Msg("Error getting block number")
return err
}
log.Trace().
Uint64("startBlockNumber", startBlockNumber).
Uint64("currStartBlockNumber", currStartBlockNumber).
Uint64("numberOfBlocksToWaitFor", numberOfBlocksToWaitFor).
Uint64("blockInterval", blockInterval).
Msg("Starting blocking loop")
Expand All @@ -745,10 +745,10 @@ func blockUntilSuccessful(ctx context.Context, c *ethclient.Client, f func() err
default:
elapsed := time.Since(start)
var blockDiff uint64
if startBlockNumber == 0 {
blockDiff = startBlockNumber
if currStartBlockNumber == 0 {
blockDiff = currStartBlockNumber
} else {
blockDiff = currentBlockNumber % startBlockNumber
blockDiff = currentBlockNumber % currStartBlockNumber
}
if blockDiff > numberOfBlocksToWaitFor {
log.Error().Err(err).Dur("elapsedTimeSeconds", elapsed).Msg("Exhausted waiting period")
Expand Down Expand Up @@ -1355,20 +1355,20 @@ func waitForFinalBlock(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Cli
ltp := inputLoadTestParams
var err error
var lastBlockNumber uint64
var currentNonce uint64
var currentNonceForFinalBlock uint64
var initialWaitCount = 50
var maxWaitCount = initialWaitCount
for {
lastBlockNumber, err = c.BlockNumber(ctx)
if err != nil {
return 0, err
}
currentNonce, err = c.NonceAt(ctx, *ltp.FromETHAddress, new(big.Int).SetUint64(lastBlockNumber))
currentNonceForFinalBlock, err = c.NonceAt(ctx, *ltp.FromETHAddress, new(big.Int).SetUint64(lastBlockNumber))
if err != nil {
return 0, err
}
if currentNonce < endNonce && maxWaitCount > 0 {
log.Trace().Uint64("endNonce", endNonce).Uint64("currentNonce", currentNonce).Msg("Not all transactions have been mined. Waiting")
if currentNonceForFinalBlock < endNonce && maxWaitCount > 0 {
log.Trace().Uint64("endNonce", endNonce).Uint64("currentNonceForFinalBlock", currentNonceForFinalBlock).Msg("Not all transactions have been mined. Waiting")
time.Sleep(5 * time.Second)
maxWaitCount = maxWaitCount - 1
continue
Expand All @@ -1379,7 +1379,7 @@ func waitForFinalBlock(ctx context.Context, c *ethclient.Client, rpc *ethrpc.Cli
break
}

log.Trace().Uint64("currentNonce", currentNonce).Uint64("startblock", startBlockNumber).Uint64("endblock", lastBlockNumber).Msg("It looks like all transactions have been mined")
log.Trace().Uint64("currentNonceForFinalBlock", currentNonceForFinalBlock).Uint64("startblock", startBlockNumber).Uint64("endblock", lastBlockNumber).Msg("It looks like all transactions have been mined")
return lastBlockNumber, nil
}

Expand Down

0 comments on commit f0d0541

Please sign in to comment.