Class CachedRenderingService

java.lang.Object
net.finmath.smartcontracts.representablestate.cache.CachedRenderingService

public final class CachedRenderingService extends Object
Opt-in cache boundary for deterministic, block-pinned renderer operations.

The L1 key contains the full chain snapshot, normalized contract address, operation, and every rendering-mode argument. When explicitly enabled with a finality verifier, an L1 miss may also use a block-neutral L2 entry keyed by the optional on-chain state witness. Failed and null results are not retained, and concurrent requests for the same enabled key share one computation.

  • Constructor Details

    • CachedRenderingService

      public CachedRenderingService(EvmXmlRenderer renderer, RendererCacheOptions options)
      Creates a cached facade around one renderer configuration.

      This convenience overload does not perform a post-render snapshot verification. Use the three-argument constructor when the caller does not verify canonicality externally.

      Parameters:
      renderer - Renderer connected to the snapshot's chain.
      options - Cache enablement, bounds, and expiry.
    • CachedRenderingService

      public CachedRenderingService(EvmXmlRenderer renderer, RendererCacheOptions options, EvmSnapshotVerifier snapshotVerifier)
      Creates a cached facade with a post-render canonicality check.
      Parameters:
      renderer - Renderer connected to the snapshot's chain.
      options - Cache enablement, bounds, and expiry.
      snapshotVerifier - Check invoked after a newly computed rendering and before it is returned or cached.
    • CachedRenderingService

      public CachedRenderingService(EvmXmlRenderer renderer, RendererCacheOptions options, EvmSnapshotVerifier snapshotVerifier, EvmSnapshotFinalityVerifier finalityVerifier)
      Creates a cached facade with canonicality and finality checks.

      Supplying a finality verifier enables cross-finalized-block reuse. It is deliberately separate from the ordinary snapshot verifier: every reusable source and target must pass both policies. A null verifier leaves cross-block reuse disabled for the convenience constructors.

      Parameters:
      renderer - Renderer connected to the snapshot's chain.
      options - Cache enablement, bounds, and expiry.
      snapshotVerifier - Canonical block-hash verification.
      finalityVerifier - Host-specific finality verification, or null to leave cross-block reuse disabled.
  • Method Details

    • render

      public String render(EvmSnapshot snapshot, String contractAddress) throws Exception
      Renders complete contract state at a fixed snapshot.
      Parameters:
      snapshot - Fixed chain and block identity.
      contractAddress - Contract to render.
      Returns:
      Rendered XML.
      Throws:
      Exception - If rendering fails.
    • renderPart

      public String renderPart(EvmSnapshot snapshot, String contractAddress, BigInteger partId) throws Exception
      Renders one state part at a fixed snapshot.
      Parameters:
      snapshot - Fixed chain and block identity.
      contractAddress - Contract to render.
      partId - Non-negative state-part identifier.
      Returns:
      Rendered XML part.
      Throws:
      Exception - If rendering fails.
    • renderTemplate

      public String renderTemplate(EvmSnapshot snapshot, String contractAddress, boolean resolveXIncludes) throws Exception
      Renders a raw or XInclude-expanded template at a fixed snapshot.
      Parameters:
      snapshot - Fixed chain and block identity.
      contractAddress - Contract whose template is loaded.
      resolveXIncludes - Whether to resolve XIncludes.
      Returns:
      Raw or expanded XML template.
      Throws:
      Exception - If loading or expansion fails.
    • clear

      public void clear()
      Clears all rendered XML retained by this facade.