╭ changed ─────────╮ │src/event/Fork.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │ 3 const xit = @import("xit"); │ │ 4 const hash = xit.hash; │ │ 5 │ │ 6 -repo_id: []const u8, │ │ 6 +repo_id: [evt.event_id_size * 2]u8, │ │ 7 // the target repo's owner, whose user repo holds the target │ │ 8 -repo_user_id: []const u8, │ │ 8 +repo_user_id: [evt.event_id_size * 2]u8, │ │ 9 stage: Stage = .draft, │ │10 │ │11 // what the db stores: the event's data plus the commit-derived fields│ ╰──────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │30 pub const repo_to_draft_id_set_key = "repo->draft-id-set"; │ │31 │ │32 fn validate(record: Record) !void { │ │33 - if (record.event.repo_id.len != evt.event_id_size) return error.InvalidRepoId; │ │34 - if (record.event.repo_user_id.len != evt.event_id_size) return error.InvalidUserId;│ │33 + _ = try evt.parseEventId(&record.event.repo_id); │ │34 + _ = try evt.parseEventId(&record.event.repo_user_id); │ │35 } │ │36 │ │37 pub fn consume( │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │59 if (!record.removed) try validate(record); │ │60 │ │61 if (existing_maybe) |existing| { │ │62 - if (!std.mem.eql(u8, existing.event.repo_id, record.event.repo_id) or │ │63 - !std.mem.eql(u8, existing.event.repo_user_id, record.event.repo_user_id)) return error.ForkChanged; │ │62 + if (!std.mem.eql(u8, &existing.event.repo_id, &record.event.repo_id) or │ │63 + !std.mem.eql(u8, &existing.event.repo_user_id, &record.event.repo_user_id)) return error.ForkChanged; │ │64 if (existing.event.stage == .publish and record.event.stage != .publish) return error.ForkAlreadyPublished;│ │65 record.created_order = existing.created_order; │ │66 if (!existing.removed) { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │67 const order_key = evt.orderKeyDesc(existing.created_order, event_id); │ │68 _ = try active.remove(&order_key); │ │69 if (existing.event.stage == .draft) { │ │70 - try removeFromParentSet(DB, hash_kind, drafts, existing.event.repo_id, &order_key); │ │70 + try removeFromParentSet(DB, hash_kind, drafts, &try evt.parseEventId(&existing.event.repo_id), &order_key);│ │71 } │ │72 } │ │73 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │85 if (!record.removed) { │ │86 try active.put(&order_key); │ │87 if (record.event.stage == .draft) { │ │88 - const by_repo = try DB.SortedSet(.read_write).init(try drafts.putCursor(hash.hashInt(hash_kind, record.event.repo_id)));│ │88 + const repo_id = try evt.parseEventId(&record.event.repo_id); │ │89 + const by_repo = try DB.SortedSet(.read_write).init(try drafts.putCursor(hash.hashInt(hash_kind, &repo_id))); │ │90 try by_repo.put(&order_key); │ │91 } │ │92 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │ 96 comptime DB: type, │ │ 97 comptime hash_kind: hash.HashKind, │ │ 98 index: DB.HashMap(.read_write), │ │ 98 - parent_id: []const u8, │ │ 99 + parent_id: *const [evt.event_id_size]u8, │ │100 order_key: *const [@sizeOf(u64) + evt.event_id_size]u8, │ │101 ) !void { │ │102 const cursor = try index.putCursor(hash.hashInt(hash_kind, parent_id));│ ╰────────────────────────────────────────────────────────────────────────────────╯