╭ changed ─────────╮ │src/event/User.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────╮ │32 pub const merge_policy: evt.MergePolicy = .target_wins; │ │33 pub const record_map_key = "event-id->user"; │ │34 pub const all_id_set_key = "user-id-set"; │ │35 -pub const active_id_set_key = "active-user-id-set"; │ │35 pub const name_index_key = "name->user-id"; │ │36 │ │37 // resolves a commit's author email to its user at read time│ ╰────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │68 const event_id_to_user_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "event-id->user")); │ │69 const event_id_to_user = try DB.HashMap(.read_write).init(event_id_to_user_cursor); │ │70 │ │72 - const name_to_user_id_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "name->user-id")); │ │73 - const name_to_user_id = try DB.HashMap(.read_write).init(name_to_user_id_cursor); │ │71 + const name_to_user_id_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, name_index_key)); │ │72 + const name_to_user_id = try DB.SortedMap(.read_write).init(name_to_user_id_cursor); │ │73 │ │74 const email_to_user_id_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, email_to_user_id_key));│ │75 const email_to_user_id = try DB.HashMap(.read_write).init(email_to_user_id_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │91 │ │92 // drop the old active indexes; active values are re-added below │ │93 if (!existing_record.removed) { │ │95 - _ = try name_to_user_id.remove(hash.hashInt(hash_kind, existing_record.event.name)); │ │94 + _ = try name_to_user_id.remove(existing_record.event.name); │ │95 _ = try email_to_user_id.remove(hash.hashInt(hash_kind, existing_record.event.email));│ │96 } │ │97 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │110 try user_id_set.put(&order_key); │ │111 } │ │112 │ │114 - const active = try DB.SortedSet(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, active_id_set_key)));│ │115 - if (record_to_write.removed) { │ │116 - _ = try active.remove(&order_key); │ │117 - } else { │ │118 - try active.put(&order_key); │ │119 - try name_to_user_id.put(hash.hashInt(hash_kind, record_to_write.event.name), .{ .bytes = event_id }); │ │113 + if (!record_to_write.removed) { │ │114 + try name_to_user_id.put(record_to_write.event.name, .{ .bytes = event_id }); │ │115 try email_to_user_id.put(hash.hashInt(hash_kind, record_to_write.event.email), .{ .bytes = event_id }); │ │116 } │ │117 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │146 name: []const u8, │ │147 password: []const u8, │ │148 ) !VerifyResult { │ │154 - const name_index_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "name->user-id")) orelse return .unknown_user; │ │155 - const name_index = try DB.HashMap(.read_only).init(name_index_cursor); │ │156 - │ │157 - const user_id_cursor = try name_index.getCursor(hash.hashInt(hash_kind, name)) orelse return .unknown_user; │ │158 - var user_id: [evt.event_id_size]u8 = undefined; │ │159 - _ = try user_id_cursor.readBytes(&user_id); │ │149 + const user_id = try readIdByName(DB, hash_kind, haxy_moment, name) orelse return .unknown_user; │ │150 │ │151 const user_key = hash.hashInt(hash_kind, &user_id); │ │152 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->user")) orelse return .unknown_user;│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │202 haxy_moment: DB.HashMap(.read_only), │ │203 name: []const u8, │ │204 ) !?[evt.event_id_size]u8 { │ │215 - return try readIdFromIndex(DB, hash_kind, haxy_moment, name_index_key, name); │ │205 + const index_cursor = (try haxy_moment.getCursor(hash.hashInt(hash_kind, name_index_key))) orelse return null;│ │206 + const index = try DB.SortedMap(.read_only).init(index_cursor); │ │207 + const user_id_cursor = (try index.getCursor(name)) orelse return null; │ │208 + var user_id: [evt.event_id_size]u8 = undefined; │ │209 + _ = try user_id_cursor.readBytes(&user_id); │ │210 + return user_id; │ │211 } │ │212 │ │213 // a user's id via the email->user-id index │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │216 comptime hash_kind: hash.HashKind, │ │217 haxy_moment: DB.HashMap(.read_only), │ │218 email: []const u8, │ │224 -) !?[evt.event_id_size]u8 { │ │225 - return try readIdFromIndex(DB, hash_kind, haxy_moment, email_to_user_id_key, email); │ │226 -} │ │227 - │ │228 -fn readIdFromIndex( │ │229 - comptime DB: type, │ │230 - comptime hash_kind: hash.HashKind, │ │231 - haxy_moment: DB.HashMap(.read_only), │ │232 - index_key: []const u8, │ │233 - key: []const u8, │ │219 ) !?[evt.event_id_size]u8 { │ │235 - const index_cursor = (try haxy_moment.getCursor(hash.hashInt(hash_kind, index_key))) orelse return null; │ │220 + const index_cursor = (try haxy_moment.getCursor(hash.hashInt(hash_kind, email_to_user_id_key))) orelse return null;│ │221 const index = try DB.HashMap(.read_only).init(index_cursor); │ │237 - const user_id_cursor = (try index.getCursor(hash.hashInt(hash_kind, key))) orelse return null; │ │222 + const user_id_cursor = (try index.getCursor(hash.hashInt(hash_kind, email))) orelse return null; │ │223 var user_id: [evt.event_id_size]u8 = undefined; │ │224 _ = try user_id_cursor.readBytes(&user_id); │ │225 return user_id; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │255 │ │256 const moment = try evt.currentMoment(evt.admin_repo_opts, &repo); │ │257 │ │273 - const name_to_user_id_cursor = try moment.getCursor(hash.hashInt(evt.admin_repo_opts.hash, "name->user-id")) orelse return null;│ │274 - const name_to_user_id = try evt.AdminDB.HashMap(.read_only).init(name_to_user_id_cursor); │ │275 - const user_id_cursor = try name_to_user_id.getCursor(hash.hashInt(evt.admin_repo_opts.hash, name)) orelse return null; │ │276 - var user_id: [evt.event_id_size]u8 = undefined; │ │277 - _ = try user_id_cursor.readBytes(&user_id); │ │258 + const user_id = try readIdByName(evt.AdminDB, evt.admin_repo_opts.hash, moment, name) orelse return null; │ │259 │ │260 return try readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, &user_id); │ │261 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯