Skip to content

Commit

Permalink
made generate_eoa_transactions task more resilent against RPC errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 12, 2024
1 parent f1f8960 commit 715430e
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions pkg/coordinator/tasks/generate_eoa_transactions/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@ func (t *Task) Execute(ctx context.Context) error {
totalCount := 0

for {
if pendingChan != nil {
select {
case <-ctx.Done():
return nil
case pendingChan <- true:
}
}

txIndex := t.txIndex
t.txIndex++

Expand All @@ -185,6 +177,14 @@ func (t *Task) Execute(ctx context.Context) error {
if err != nil {
t.logger.Errorf("error generating transaction: %v", err.Error())
} else {
if pendingChan != nil {
select {
case <-ctx.Done():
return nil
case pendingChan <- true:
}
}

perBlockCount++
totalCount++
}
Expand Down Expand Up @@ -317,13 +317,21 @@ func (t *Task) generateTransaction(ctx context.Context, transactionIdx uint64, c
}
}

client := clients[transactionIdx%uint64(len(clients))]
err = nil

for i := 0; i < len(clients); i++ {
client := clients[(transactionIdx+uint64(i))%uint64(len(clients))]

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx %v: %v", transactionIdx, tx.Hash().Hex())

t.logger.WithFields(logrus.Fields{
"client": client.GetName(),
}).Infof("sending tx %v: %v", transactionIdx, tx.Hash().Hex())
err = client.GetRPCClient().SendTransaction(ctx, tx)
if err == nil {
break
}
}

err = client.GetRPCClient().SendTransaction(ctx, tx)
if err != nil {
return err
}
Expand Down

0 comments on commit 715430e

Please sign in to comment.