MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / scan_find_block_end

Function scan_find_block_end

atomic-core/src/pristine/txn/write/graph.rs:323–358  ·  view source on GitHub ↗
(
        vertices: &[(u64, u64, u64)],
        change_id: u64,
        target_pos: u64,
    )

Source from the content-addressed store, hash-verified

321 }
322
323 fn scan_find_block_end(
324 vertices: &[(u64, u64, u64)],
325 change_id: u64,
326 target_pos: u64,
327 ) -> Option<GraphNode<NodeId>> {
328 if vertices
329 .iter()
330 .any(|&(c, s, e)| c == change_id && s == target_pos && e == target_pos)
331 {
332 return Some(GraphNode {
333 change: NodeId::new(change_id),
334 start: ChangePosition::new(target_pos),
335 end: ChangePosition::new(target_pos),
336 });
337 }
338 for &(v_change, v_start, v_end) in vertices {
339 if v_change != change_id {
340 continue;
341 }
342 if v_end == target_pos && v_start < v_end {
343 return Some(GraphNode {
344 change: NodeId::new(v_change),
345 start: ChangePosition::new(v_start),
346 end: ChangePosition::new(v_end),
347 });
348 }
349 if v_start <= target_pos && target_pos < v_end {
350 return Some(GraphNode {
351 change: NodeId::new(v_change),
352 start: ChangePosition::new(v_start),
353 end: ChangePosition::new(v_end),
354 });
355 }
356 }
357 None
358 }
359
360 /// Differential test: the binary-search `find_block`/`find_block_end`
361 /// must agree with the historical brute-force scan on every probe over

Calls 1

iterMethod · 0.45