factor code to save tx in-memory/on-disk.