package tezos-protocol-011-PtHangz2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The following module acts on the whole cache, not on a specific sub-cache, unlike Interface. It is used to administrate the protocol cache, e.g., to maintain the cache in a consistent state with respect to the chain. This module is typically used by low-level layers of the protocol and by the shell.

type key

A key uniquely identifies a cached value in some subcache.

type value

Cached values.

pp fmt ctxt is a pretty printter for the cache of ctxt.

set_cache_layout ctxt layout sets the caches of ctxt to comply with given layout. If there was already a cache in ctxt, it is erased by the new layout.

In that case, a fresh collection of empty caches is reconstructed from the new layout. Notice that cache keys are invalidated in that case, i.e., find t k will return None.

sync ctxt ~cache_nonce updates the context with the domain of the cache computed so far. Such function is expected to be called at the end of the validation of a block, when there is no more accesses to the cache.

cache_nonce identifies the block that introduced new cache entries. The nonce should identify uniquely the block which modifies this value. It cannot be the block hash for circularity reasons: The value of the nonce is stored onto the context and consequently influences the context hash of the very same block. Such nonce cannot be determined by the shell and its computation is delegated to the economic protocol.

val clear : context -> context

clear ctxt removes all cache entries.

Cache helpers for RPCs

val future_cache_expectation : context -> time_in_blocks:int -> context

future_cache_expectation ctxt ~time_in_blocks returns ctxt except that the entries of the caches that are presumably too old to still be in the caches in n_blocks are removed.

This function is based on a heuristic. The context maintains the median of the number of removed entries: this number is multipled by `n_blocks` to determine the entries that are likely to be removed in `n_blocks`.

val cache_size : context -> cache_index:int -> size option

cache_size ctxt ~cache_index returns an overapproximation of the size of the cache. Returns None if cache_index is greater than the number of subcaches declared by the cache layout.

val cache_size_limit : context -> cache_index:int -> size option

cache_size_limit ctxt ~cache_index returns the maximal size of the cache indexed by cache_index. Returns None if cache_index is greater than the number of subcaches declared by the cache layout.

OCaml

Innovation. Community. Security.