The upstream release tree, every tracked file byte for byte, from https://github.com/VecSzn/PolyStrata at tag v0.1.45-poly.1, commit d0cd84dc6bd009d1d9e2191e4e28cc76b80f1ee3. Nothing added, removed or edited; git diff against this commit is the whole story of the fork. Verified: the commit's tree hash equals the upstream commit's tree hash.
21 lines
716 B
C++
21 lines
716 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace strata::program {
|
|
|
|
inline int64_t message_checkpoint_boundary(const std::vector<int64_t>& ids, int64_t resume,
|
|
int64_t turn_at, int64_t turn_token, int64_t min_prefix = 8192, int64_t max_tail = 1024) {
|
|
if (resume < 0 || turn_token < 0 || turn_at <= resume || turn_at >= int64_t(ids.size()) ||
|
|
ids[std::size_t(turn_at)] != turn_token || min_prefix < 0 || max_tail <= 0) return -1;
|
|
for (int64_t i = turn_at - 1; i > resume; --i) {
|
|
if (turn_at - i > max_tail) return -1;
|
|
if (ids[std::size_t(i)] == turn_token) return i >= min_prefix ? i : -1;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
} // namespace strata::program
|