I am developing an eCommerce application that has on-chain and off-chain components. The off-chain components focus on the compute and storage intensive operation while on-chain smartcontract ensure true decentralized ownership of assets through immutable ledger records.
My usual use-case will involve a browser frontend and offchain component interacting with users. Once the workflow comes to the appropriate juncture, I will call smartcontract function for updates or transfer.
I need to track the submitted transactions and match it against my offchain DB records. I understand submitted transactions may not get executed immediately because miner may not prioritise my transaction. While my offchain system is waiting for the smartcontract function to be executed and transaction to be confirmed, what if my system is shutdown. How do I find the transactions that I sent which may or may not be confirmed when my system is back online? I hope I don't need to scan all transactions for all new blocks.
Extending on this question, in the traditional enterprise system - there is always 2 phase-commit that ensure transaction integrity across multiple components. What is the best practice and design pattern if I want to implement something similar? I understand there is no way to rollback transaction in blockchain so we can forget about the rollback part in the 2 phase-commit, I just need to deal with out-of-sync system states and recover from it.