ForkLedgerStore class

A LedgerStore wrapper that injects a synthetic ForkRecord entry at seq 0.

When to use

This lets Ledger and Ledger.verify operate on a fork without changing their implementation — the fork is just a ledger whose genesis happens to be a ForkRecord.

Non-obvious: the synthetic entry is a real chain entry

Its hash is computed by the same HashChain.nextHash every other entry uses (prevHash = the fork record's genesis hash, seq 0, empty pulse/effects/deltas, stable synthetic receipt). The fork's real entries then chain from that hash. Making the synthetic hash equal ForkRecord.genesisHash instead would not verify: the recomputed hash would differ from the stored one.

The synthetic entry is also injected into the inner store on the first append: the inner store's genesis check must pass against the fork record's genesis hash, and it can only pass for the synthetic entry itself.

See also:

  • ForkRecord — the record materialised as seq 0.
  • ForkHandle — the handle that owns one of these stores.
Implemented types

Constructors

ForkLedgerStore({required ForkRecord record, required LedgerStore inner})

Properties

genesisHash → String
The fork's chain genesis. inner must have been created with this value — CellGraphFork.fork passes it to the caller's store factory.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
inner → LedgerStore
final
lastHash → Future<String?>
The current head hash, or null if the store is empty.
no setteroverride
lastSeq → Future<int>
The last sequence number, or -1 if the store is empty.
no setteroverride
record → ForkRecord
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(LedgerEntry entry) → Future<void>
Append entry to the store.
override
close() → Future<void>
Close the store. Any subsequent operation must fail.
override
entriesSince(int fromSeq) → Stream<LedgerEntry>
Iterate entries from fromSeq (inclusive) to the end.
override
materialize() → Future<void>
Writes the synthetic seq-0 ForkRecord entry into inner without appending a real entry.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited