@@ -177,11 +177,23 @@ func (atp *apiTransactionProcessor) GetTransaction(txHash string, withResults bo
177177}
178178
179179func (atp * apiTransactionProcessor ) doGetTransaction (hash []byte , withResults bool ) (* transaction.ApiTransactionResult , error ) {
180- tx := atp .optionallyGetTransactionFromPool (hash )
181- if tx != nil {
182- return tx , nil
180+ txFromPool := atp .optionallyGetTransactionFromPool (hash )
181+ if txFromPool != nil {
182+ // we don't return immediately because storage/history takes priority if it succeeds
183+ txFromStorage , err := atp .fetchFromStorageOrHistory (hash , withResults )
184+ if err == nil {
185+ return txFromStorage , nil
186+ }
187+
188+ // storage/history failed, but pool has it
189+ return txFromPool , nil
183190 }
184191
192+ // no pool entry — just return storage/history result
193+ return atp .fetchFromStorageOrHistory (hash , withResults )
194+ }
195+
196+ func (atp * apiTransactionProcessor ) fetchFromStorageOrHistory (hash []byte , withResults bool ) (* transaction.ApiTransactionResult , error ) {
185197 if atp .historyRepository .IsEnabled () {
186198 return atp .lookupHistoricalTransaction (hash , withResults )
187199 }
@@ -736,12 +748,33 @@ func (atp *apiTransactionProcessor) computeTimestampForRoundAsMs(round uint64) i
736748 return timestamp .UnixMilli ()
737749}
738750
751+ func (atp * apiTransactionProcessor ) checkExecutionResult (miniblockMetadata * dblookupext.MiniblockMetadata ) error {
752+ isSupernovaEnabled := atp .enableRoundsHandler .IsFlagEnabledInRound (common .SupernovaRoundFlag , miniblockMetadata .Round )
753+ if ! isSupernovaEnabled {
754+ return nil
755+ }
756+
757+ headerHash := miniblockMetadata .GetHeaderHash ()
758+ executionResultsStorer , errG := atp .storageService .GetStorer (dataRetriever .ExecutionResultsUnit )
759+ if errG != nil {
760+ return errG
761+ }
762+
763+ _ , err := executionResultsStorer .GetFromEpoch (headerHash , miniblockMetadata .GetEpoch ())
764+ return err
765+ }
766+
739767func (atp * apiTransactionProcessor ) lookupHistoricalTransaction (hash []byte , withResults bool ) (* transaction.ApiTransactionResult , error ) {
740768 miniblockMetadata , err := atp .historyRepository .GetMiniblockMetadataByTxHash (hash )
741769 if err != nil {
742770 return nil , fmt .Errorf ("%s: %w" , ErrTransactionNotFound .Error (), err )
743771 }
744772
773+ err = atp .checkExecutionResult (miniblockMetadata )
774+ if err != nil {
775+ return nil , fmt .Errorf ("%s: %w" , ErrTransactionNotFound .Error (), err )
776+ }
777+
745778 txBytes , txType , found := atp .getTxBytesFromStorageByEpoch (hash , miniblockMetadata .Epoch )
746779 if ! found {
747780 log .Warn ("lookupHistoricalTransaction(): unexpected condition, cannot find transaction in storage" )
0 commit comments