package tezos-protocol-017-PtNairob
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/tezos-protocol-017-PtNairob.raw/Tezos_raw_protocol_017_PtNairob/Cache_repr/index.html
Module Tezos_raw_protocol_017_PtNairob.Cache_repr
Source
Frequently used data should be kept in memory and persisted along a chain of blocks. The caching mechanism allows the economic protocol to declare such data and to rely on a Least Recently Used strategy to keep the cache size under a fixed limit.
Take a look at Environment_cache
and Environment_context
for additional implementation details about the protocol cache.
The protocol has two main kinds of interaction with the cache:
1. It is responsible for setting up the cache with appropriate parameter values and callbacks. It must also compute cache nonces to give the shell enough information to properly synchronize the in-memory cache with the block contexts and protocol upgrades. A typical place where this happens is Apply
. This aspect must be implemented using Cache.Admin
.
2. It can exploit the cache to retrieve, to insert, and to update cached values from the in-memory cache. The basic idea is to avoid recomputing values from scratch at each block when they are frequently used. Script_cache
is an example of such usage. This aspect must be implemented using Cache.Interface
.
Size for subcaches and values of the cache.
Index type to index caches.
Type used to identifies the block that introduced new cache entries
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.
A client uses a unique namespace (represented as a string without '@') to avoid collision with the keys of other clients.
create_namespace str
creates a valid namespace from str
A key is fully determined by a namespace and an identifier.
To use the cache, a client must implement the CLIENT
interface.
An INTERFACE
to the subcache where keys live in a given namespace
.
val register_exn :
(module CLIENT with type cached_value = 'a) ->
(module INTERFACE
with type cached_value = 'a)
register_exn client
produces an Interface
specific to a given client
. This function can fail if client
does not respect the invariant declared in the documentation of CLIENT
.
val cache_nonce_from_block_header :
Block_header_repr.shell_header ->
Block_header_repr.contents ->
cache_nonce
cache_nonce_from_block_header shell_header contents
computes a cache_nonce
from the shell_header
and its contents
.