package tezos-protocol-alpha
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
doc/tezos_raw_protocol_alpha/Tezos_raw_protocol_alpha/Cache_repr/index.html
Module Tezos_raw_protocol_alpha.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
.