Skip to content

Documentation / @etherfold/browser / EventProcessor

Type Alias: EventProcessor<ABI, ProcessResultType> ​

EventProcessor<ABI, ProcessResultType> = object

Defined in: packages/core/dist/types.d.ts:222

Type Parameters ​

ABI ​

ABI extends Abi

ProcessResultType ​

ProcessResultType = void

Properties ​

clear ​

clear: () => Promise<void>

Defined in: packages/core/dist/types.d.ts:286

Returns ​

Promise<void>


load ​

load: (source, streamConfig) => Promise<{ lastSync: LastSync<ABI>; state: ProcessResultType; } | undefined>

Defined in: packages/core/dist/types.d.ts:280

PREPARE THIS FOLD TO ADVANCE, and answer its persisted state and cursor, or undefined when it has folded nothing.

It is handed the source THIS FOLD folds under, and only ever that one. A processor MAY key its cursor by source and answer undefined for a source it never folded under; neither shipped implementation does (their cursor is keyed by the generation's own namespace, ADR-0053), which is exactly why a caller handing the WRONG source would go unnoticed, so the callers are what guarantee it. The callers are the engines that DRIVE one fold, each built with that fold's own source (IndexerGeneration on the chain-facing container, GenerationRebuild on the receiving one, StreamBuilder for a lone receiver), and the one-shot preparations of a fold about to be driven (replayFixtureInto, the CLI's index start-up). No container calls it with a source of its own.

It is not a READ, and no cursor read goes through it. It may write: the entity processors record the finality, run their migrations and check retention here, so it belongs to the advance path, which is where it is called. What a container COMPARES or REPORTS -- the promotion trigger, /status, folding() -- is read without it: the chain-facing container keeps the cursor each engine last reported, and the receiving one reads the persisted cursor by identity (GenerationRegistryPort.readStateCursor), which also answers for a generation this process holds no fold for. Pinned by packages/core/test/aFoldIsLoadedOnlyWithTheSourceItFolds.test.ts, with a double that honours source.

Parameters ​

source ​

IndexingSource<ABI>

streamConfig ​

UsedStreamConfig

Returns ​

Promise<{ lastSync: LastSync<ABI>; state: ProcessResultType; } | undefined>


process ​

process: (eventStream, lastSync) => Promise<ProcessResultType>

Defined in: packages/core/dist/types.d.ts:284

Parameters ​

eventStream ​

LogEvent<ABI>[]

lastSync ​

LastSync<ABI>

Returns ​

Promise<ProcessResultType>


reset ​

reset: () => Promise<void>

Defined in: packages/core/dist/types.d.ts:285

Returns ​

Promise<void>


setFoldReporter? ​

optional setFoldReporter?: (reporter) => void

Defined in: packages/core/dist/types.d.ts:310

ATTACH THE FOLD-REPORT CHANNEL: where this fold reports each block it applied with the entity names that block touched (AppliedBlock), and each branch it took back with the fork point it kept (Retraction).

ONE SLOT, owned by whoever DRIVES this processor -- a container sets it when it builds a generation and again when a reconfigure swaps the fold in place, and undefined detaches. It is not a subscription: the fan-out to readers is the container's (StateMovedPublisher), and a second list here would be a second place for it to go wrong.

OPTIONAL, unlike getCodeFingerprint beside it, and the asymmetry is deliberate: a fingerprint is something every processor can answer, while naming the entities a block touched is something only a fold with entity declarations CAN do -- and making it required would change the seam for processor-sqlite, the CLI and the browser to add a method most of them would implement as a no-op. The cost is the one an optional method always has: a WRAPPER that forgets to forward it takes the wrapped fold's reporting down with it silently, which is why VersionedStateEventProcessor forwarding it is pinned by a test of its own. A processor that implements nothing here publishes NO signal rather than a fabricated one; core cannot know what such a fold applied, nor what it took back.

Parameters ​

reporter ​

FoldReporter | undefined

Returns ​

void

Methods ​

getCodeFingerprint() ​

getCodeFingerprint(): string | undefined

Defined in: packages/core/dist/types.d.ts:253

A hash of the processor's own handler SOURCE, or undefined when it cannot be derived.

IT IS AN IDENTITY, in the one arrival that has no bytes to hash. ADR-0086 derives identity PER ARRIVAL and the engine is HANDED one (GenerationSpec.processorIdentity, StreamBuilderOptions.processorIdentity, IndexerGenerationOptions.processorIdentity): a processor that arrived as BYTES is named by the SHA-256 of those octets, and a processor a dev server handed a tab as a MODULE OBJECT has no octets at all, so @etherfold/browser names that fold with exactly this value (moduleProcessorIdentity, built by a-module-handed-to-a-tab-is-identified-by-its-handler-sources, which is why this method outlived the declared identity). Nothing in core calls it: core only COMPARES the identity it was handed.

It used to have a SECOND role -- an advisory second opinion beside an author-declared version, reported as a drift report when the two disagreed -- and that role went with the declared identity it was a second opinion about (the-declared-version-and-the-drift-report-are-deleted). What is left is the derivation itself, as a name.

REQUIRED, unlike the value it returns. An optional method is a hole with a polite name: a WRAPPER (a cache, a decorator) that forgot to forward it would silently rename the fold underneath it -- or leave it unnameable -- and being required makes that a compile error instead. Returning undefined is still allowed, because "cannot tell" is a real answer (a processor whose handlers are all bound or proxied has no readable source), and the arrival that asks is what decides what to do about it: @etherfold/browser REFUSES such a module rather than naming it something a later edit could not move.

Returns ​

string | undefined