From b015633a52ea90925e3a7c4ac65838dd9e27febe Mon Sep 17 00:00:00 2001 From: Iulian Pascalau Date: Mon, 12 Aug 2024 21:59:40 +0300 Subject: [PATCH] - refactor --- pkg/facade/simulatorFacade.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/pkg/facade/simulatorFacade.go b/pkg/facade/simulatorFacade.go index 999fa1e..08106fe 100644 --- a/pkg/facade/simulatorFacade.go +++ b/pkg/facade/simulatorFacade.go @@ -18,7 +18,7 @@ import ( const ( errMsgAccountNotFound = "account was not found" maxNumOfBlockToGenerateUntilTxProcessed = 20 - initialBlocksToBeGenerated = 5 + initialBlocksToBeGenerated = 1 ) type simulatorFacade struct { @@ -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 {