MCPcopy Create free account
hub / github.com/Niko1221/Strata / check_chain

Function check_chain

engine/src/core/coupled_draft_test.cpp:34–43  ·  view source on GitHub ↗

The counters and positions of a chain of `n` drafts made after a window at `p` with `a` accepted (draft()), or for draft_first (cell0 = p - 1, a = 0), checked against the next window at `p_next`.

Source from the content-addressed store, hash-verified

32// The counters and positions of a chain of `n` drafts made after a window at `p` with `a` accepted (draft()), or for
33// draft_first (cell0 = p - 1, a = 0), checked against the next window at `p_next`.
34void check_chain(int64_t p, int a, int n, int64_t p_next) {
35 for (int j = 0; j < n; ++j) {
36 const int64_t cell = coupled_draft_cell(p, a, j);
37 // mtp.hpp: cell c predicts the token at c + 2; the next window's row j + 1 holds position p_next + j + 1
38 check(cell + 2 == p_next + j + 1, "draft position = its row in the next window", cell + 2, p_next + j + 1);
39 // row j + 1 is kept iff it equals row j's pick, drawn at p_next + j
40 check(coupled_draft_counter(cell) == verify_row_counter(p_next, j), "draft counter = verifying row's counter",
41 (long long) coupled_draft_counter(cell), (long long) verify_row_counter(p_next, j));
42 }
43}
44
45// The device ring for one chain: base staged at [cap - h, cap) by the host, draft i at cap + i; draft j's window is
46// [coupled_hist_start(cap, j, h), + h). Compared with penalty_rows over (consumed, [next, drafts...]).

Callers 1

mainFunction · 0.85

Calls 4

verify_row_counterFunction · 0.85
checkFunction · 0.70
coupled_draft_cellFunction · 0.50
coupled_draft_counterFunction · 0.50

Tested by

no test coverage detected