| 14 | } |
| 15 | |
| 16 | export function buildSearchContext(state: SessionState, rawMessages: WithParts[]): SearchContext { |
| 17 | const rawMessagesById = new Map<string, WithParts>() |
| 18 | const rawIndexById = new Map<string, number>() |
| 19 | for (const msg of rawMessages) { |
| 20 | rawMessagesById.set(msg.info.id, msg) |
| 21 | } |
| 22 | for (let index = 0; index < rawMessages.length; index++) { |
| 23 | const message = rawMessages[index] |
| 24 | if (!message) { |
| 25 | continue |
| 26 | } |
| 27 | rawIndexById.set(message.info.id, index) |
| 28 | } |
| 29 | |
| 30 | const summaryByBlockId = new Map() |
| 31 | for (const [blockId, block] of state.prune.messages.blocksById) { |
| 32 | if (!block.active) { |
| 33 | continue |
| 34 | } |
| 35 | summaryByBlockId.set(blockId, block) |
| 36 | } |
| 37 | |
| 38 | return { |
| 39 | rawMessages, |
| 40 | rawMessagesById, |
| 41 | rawIndexById, |
| 42 | summaryByBlockId, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export function resolveBoundaryIds( |
| 47 | context: SearchContext, |