100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#include "reference_ledger.hpp"
|
|
|
|
namespace reference {
|
|
|
|
int Ledger::apply(const Op &operation)
|
|
{
|
|
switch (operation.kind) {
|
|
case 1:
|
|
return get(operation.id, operation.cpu, operation.amount);
|
|
case 2:
|
|
return put(operation.id, operation.cpu, operation.amount);
|
|
case 3:
|
|
return fold_cpu(operation.id, operation.cpu);
|
|
case 4:
|
|
return fold_all(operation.id);
|
|
case 5:
|
|
return kill(operation.id);
|
|
case 6:
|
|
return erase(operation.id);
|
|
default:
|
|
return -22;
|
|
}
|
|
}
|
|
|
|
int Ledger::batch(const std::vector<Op> &operations,
|
|
std::vector<Number> &totals)
|
|
{
|
|
if (operations.size() > 64) {
|
|
return -22;
|
|
}
|
|
Ledger proposed = *this;
|
|
std::vector<Number> observed;
|
|
observed.reserve(operations.size());
|
|
for (const Op &operation : operations) {
|
|
const int status = proposed.apply(operation);
|
|
if (status != 0) {
|
|
return status;
|
|
}
|
|
if (operation.kind == 6) {
|
|
observed.push_back(0);
|
|
} else {
|
|
Number value = 0;
|
|
const int read_status = proposed.total(operation.id, value);
|
|
if (read_status != 0) {
|
|
return read_status;
|
|
}
|
|
observed.push_back(value);
|
|
}
|
|
}
|
|
*this = proposed;
|
|
totals = observed;
|
|
return 0;
|
|
}
|
|
|
|
}
|