Skip to content

Commit

Permalink
- refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau committed Aug 12, 2024
1 parent 1b0aa23 commit b015633
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions pkg/facade/simulatorFacade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const (
errMsgAccountNotFound = "account was not found"
maxNumOfBlockToGenerateUntilTxProcessed = 20
initialBlocksToBeGenerated = 5
initialBlocksToBeGenerated = 1
)

type simulatorFacade struct {
Expand Down Expand Up @@ -180,30 +180,23 @@ func (sf *simulatorFacade) GenerateBlocksUntilTransactionIsProcessed(txHash stri
return err
}

txStatusInfo, err := sf.transactionHandler.GetProcessedTransactionStatus(txHash)
if err != nil {
return err
}

count := 0
for txStatusInfo.Status == transaction.TxStatusPending.String() {
for i := 0; i < maxNumOfBlockToGenerateUntilTxProcessed; i++ {
err = sf.GenerateBlocks(1)
if err != nil {
return err
}

txStatusInfo, err = sf.transactionHandler.GetProcessedTransactionStatus(txHash)
if err != nil {
return err
txStatusInfo, errGet := sf.transactionHandler.GetProcessedTransactionStatus(txHash)
if errGet != nil {
return errGet
}

count++
if count > maxNumOfBlockToGenerateUntilTxProcessed {
return errors.New("something went wrong, transaction is still in pending")
if txStatusInfo.Status != transaction.TxStatusPending.String() {
return nil
}
}

return nil
return errors.New("something went wrong, transaction is still in pending")
}

func (sf *simulatorFacade) getCurrentEpoch() uint32 {
Expand Down

0 comments on commit b015633

Please sign in to comment.