Checkpoint: the ledger, proven
Challenge on lesson: Checkpoint: The Ledger, Proven
Copy your Engine/InMemory/JsonlFile/replay and LedgerService into Solution, then add:
1. static String report(LedgerService svc, java.util.List<String> keys,
java.util.concurrent.Executor exec) — per key, supplyAsync(() -> key + "=" +
svc.get(key), exec) with orTimeout(50, MILLISECONDS) and handle → key + "=down" on
failure; allOf(...).orTimeout(500, MILLISECONDS).join(); join parts in submission
order, joined with ",".
2. static String prove(String seed) — the proof: build a JsonlFile over a fresh
temp file, record seed/a=1, seed/b=2 through a LedgerService; build an InMemory
engine, record the SAME operations through another LedgerService; run report(
..., List.of("a","b"), sameExecutor) on both; return the two report strings
joined with "|" — they must be IDENTICAL strings for the test to pass.
3. static boolean survivesRestart(java.nio.file.Path file) — engine over file,
record x=9; build a SECOND service via replay(file); return whether the replayed
service get("x") equals "9".
Difficulty: advanced
Back to lesson: Checkpoint: The Ledger, Proven