╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Grant.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
111 112 // a target's active grants, newest first 113 pub fn readByTarget( 114 comptime DB: type, 115 comptime hash_kind: hash.HashKind, 116 haxy_moment: DB.HashMap(.read_only), 117 arena: *std.heap.ArenaAllocator, 118 target_id: *const [evt.event_id_size]u8, 119 ) ![]const Self { 120 var grants: std.ArrayList(Self) = .empty; 121 const by_target_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, target_to_grant_id_set_key)) orelse return grants.items; 122 const by_target = try DB.HashMap(.read_only).init(by_target_cursor); 123 const target_grants_cursor = try by_target.getCursor(hash.hashInt(hash_kind, target_id)) orelse return grants.items; 124 const target_grants = try DB.SortedSet(.read_only).init(target_grants_cursor); 125 126 var iter = try target_grants.iteratorFromIndex(0); 127 while (try iter.next()) |kv_cursor| { 128 const grant_id = try evt.readOrderKeyId(DB, kv_cursor); 129 const grant = (try evt.readRecordSubset(Self, struct { event: Self }, DB, hash_kind, haxy_moment, arena, &grant_id)) orelse continue; 130 try grants.append(arena.allocator(), grant.event); 131 } 132 return grants.items; 133 } 134