diff options
Diffstat (limited to 'src/tape.zig')
| -rw-r--r-- | src/tape.zig | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/tape.zig b/src/tape.zig index 3774261c..ced8b9bf 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -403,7 +403,7 @@ pub const Tape = struct { .input => t.apply(&rec.payload), .set => t.applySet(&rec.payload), .host => t.skipHost(), - .digest => t.check(&rec.payload), + .digest => t.check(rec.payload.bytes), .done => return t.diverge("a host call's records are out of order", .{}), } } @@ -435,7 +435,7 @@ pub const Tape = struct { .set => t.applySet(&rec.payload), .host => if (t.headless) t.skipHost() else return t.diverge("the core did not make the host call {d} the tape has", .{std.mem.bytesToValue(u16, rec.payload.bytes[0..2])}), .input => t.apply(&rec.payload), - .digest => t.check(&rec.payload), + .digest => t.check(rec.payload.bytes), .ret => return t.diverge("the core's input ended before the recorded one", .{}), } } @@ -456,7 +456,7 @@ pub const Tape = struct { }, .input => t.apply(&rec.payload), .set => t.applySet(&rec.payload), - .digest => t.check(&rec.payload), + .digest => t.check(rec.payload.bytes), .host, .done => { t.diverge("a host call's records are out of order", .{}); return false; @@ -483,9 +483,11 @@ pub const Tape = struct { return t.finishHost(); } - /// A recorded digest against the replica's own. - fn check(t: *Tape, r: *walk.Reader) void { - const want = walk.decode([]const u64, r, t.arena.allocator()) catch return; + /// A digest record's payload (a unit's last) against the core's own: a + /// difference is `diverged`, its fields named when the record has them. + pub fn check(t: *Tape, payload: []const u8) void { + var r: walk.Reader = .{ .bytes = payload }; + const want = walk.decode([]const u64, &r, t.arena.allocator()) catch return; const p = t.core orelse return; var parts: Parts = undefined; const whole = [1]u64{digestOf(p)}; @@ -954,13 +956,6 @@ pub fn recordDigest(t: *Tape) void { t.record(.digest, []const u64, &d); } -/// The core's digest against a digest record's payload (a unit's last): a -/// difference is `diverged`, its fields named when the record has them. -pub fn checkDigest(t: *Tape, payload: []const u8) void { - var r: walk.Reader = .{ .bytes = payload }; - t.check(&r); -} - /// A core made outside the tape (a replica client's, from a dump) is the /// one it replays into. pub fn adoptCore(t: *Tape, p: *Pardes) void { @@ -1094,15 +1089,6 @@ pub fn release(t: *Tape) void { if (t.kept_arena) |*k| k.deinit(); } -/// What was recorded since the last take; the tape's to reuse after. -pub fn taken(t: *Tape) []const u8 { - return t.buf.items; -} - -pub fn clearTaken(t: *Tape) void { - t.buf.clearRetainingCapacity(); -} - /// The records of `bytes`, top-level inputs and all, applied to the /// tape's core as the authority applied them, each digest checked; why /// they diverged, or null. @@ -1120,7 +1106,7 @@ pub fn replayUnit(t: *Tape, bytes: []const u8) ?[]const u8 { _ = t.arena.reset(.retain_capacity); }, .set => t.applySet(&rec.payload), - .digest => t.check(&rec.payload), + .digest => t.check(rec.payload.bytes), .host, .ret, .done => t.diverge("a {t} record at the top", .{kind}), } } |
