RAILGUN Reloaded
    Preparing search index...

    RailgunEngine

    Core orchestrator for the Railgun protocol. Manages initialization and lifecycle of all critical components required for Railgun operation like

    • Prover: Cryptographic proof generation engine
    • DataSync: Blockchain data synchronization service
    • ArtifactFetcher: Resource and artifact retrieval service
    Index
    • get db(): any

      Get Chain DB Instance

      Returns any

      ChainDB Instance

      Use storage instead — all chain reads and writes go through the ChainStorage contract. This raw handle remains only as a Node-side escape hatch and will be removed once no consumer needs it.

    • Construct an engine. Pass chainDB to inject a pre-configured database (for tests). When omitted, the engine creates <dataDir>/chains/<id>/chain.db the first time storage is requested (dataDir defaults to ./.railgun).

      Parameters

      • options: { chainId: number; chainDB?: any; dataDir?: string; prover?: Groth16Prover }

        Required { chainId }, optional { chainDB?, dataDir?, prover? }.

        • chainId: number

          EVM chain ID of the one chain this engine serves.

        • OptionalchainDB?: any

          Pre-built ChainDB; engine will not close it. When provided, dataDir is ignored.

        • OptionaldataDir?: string

          Base directory for chain DB files. Defaults to ./.railgun.

        • Optionalprover?: Groth16Prover

          Groth16 backend for proof-bearing operations. Omit when the consumer only shields.

      Returns RailgunEngine

    • Set Logger for Railgun Engine

      Parameters

      • log: (msg: string) => void

        Logger Function

      Returns void

    • Drain the data source into chain.db, returning when the source reaches its current tip. Resumes from the persisted sync cursor when one exists, otherwise starts at startBlock or the network's deployment block.

      Live sources (RPCProvider) never reach a natural tip; bound the scan with endBlock when using one. Direct engine calls are not serialized. Await each scan before starting another on the same storage or data source. RailgunClient.scan() provides a per-client queue.

      Parameters

      • options: ScanOptions

        { dataSource, startBlock?, endBlock?, onBatch? }.

        • dataSource

          Source of blocks. The caller owns it; the engine never destroys it.

        • startBlock

          Inclusive floor used only without a persisted cursor. Must be at or above the network deployment block.

        • endBlock

          Inclusive ceiling; the scan exits after writing a block at or above this height.

        • onBatch

          Fired after each batch is committed to chain.db with the resolved scan start and the highest block number in that batch. Synchronous; throwing aborts the run.

        • persistRailgunTransactions

          Whether to persist PPOI Railgun transaction rows while denormalizing blocks.

      Returns Promise<bigint | undefined>

      Last block number written to chain.db, or undefined when the source had nothing to yield.

    • Get MerkleTree by treeNumber

      Parameters

      • treeNumber: number

        Input treeNumber

      Returns NoteCommitmentTree

      • NoteCommitmentTree instance
    • Get all the note commitment tree in the engine

      Returns Map<number, NoteCommitmentTree>

      • Map of treeNumber with corresponding NoteCommitmentTree instance
    • Release engine resources: close chain.db only when the engine owns it.

      Returns Promise<void>