With a log that is potentially millions of lines long, you want to read the log file once only, or else you suffer an enormous performance penalty.
has pointed out one data structure to do that. If the transaction IDs are unique per transaction, an array of transaction hashes would be a reasonable way to go. Fill in the data as it's seen.