+ if (txn->state != TXN_RUNNING)
+ return ERROR_TXN_NOT_RUNNING;
+
+ update_t *newest_update = (update_t *) map_get(txn->map, key);
+ if (!IS_TAGGED(newest_update, TAG2))
+ return (uint64_t)newest_update;
+
+ // Iterate through the update records to find the latest committed version prior to our read version.
+ update_t *update;
+ for (update = newest_update; ; update = update->next) {
+
+ if (!IS_TAGGED(update, TAG2))
+ return (uint64_t)update;
+
+ update = (update_t *)STRIP_TAG(update, TAG2);
+ assert(update != NULL);
+
+ // If the update's version is not tagged it means the update is committed.
+ if (!IS_TAGGED(update->version, TAG1)) {
+ if (update->version <= txn->rv)
+ break; // success
+ continue;
+ }
+
+ // If the update's version is tagged then either the update was aborted or the the version number is
+ // actually a pointer to a running transaction's txn_t.
+
+ // Skip updates from aborted transactions.
+ if (EXPECT_FALSE(update->version == ABORTED_VERSION))
+ continue;
+
+ // The update's transaction is still in progress. Access its txn_t.
+ txn_t *writer = (txn_t *)STRIP_TAG(update->version, TAG1);
+ if (writer == txn) // found our own update
+ break; // success