package octez-proto-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
doc/octez-proto-libs.protocol-environment/Tezos_protocol_environment/V5/Make/Context/Cache/index.html
Module Context.CacheSource
Cached values inhabit an extensible type.
key_of_identifier ~cache_index identifier builds a key from the cache_index and the identifier.
No check are made to ensure the validity of the index.
identifier_of_key key returns the identifier associated to the key.
pp fmt cache is a pretty printter for a cache.
find ctxt k = Some v if v is the value associated to k in in the cache where k is. Returns None if there is no such value in the cache of k. This function is in the Lwt monad because if the value has not been constructed, it is constructed on the fly.
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.
Otherwise, a fresh collection of empty caches is reconstructed from the new layout. Notice that cache keys are invalidated in that case, i.e., get t k will return None.
update ctxt k (Some (e, size)) returns a cache where the value e of size is associated to key k. If k is already in the cache, the cache entry is updated.
update ctxt k None removes k from the cache.
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.
Cache introspection
list_keys ctxt ~cache_index returns the list of cached keys in cache numbered cache_index along with their respective size. The returned list is sorted in terms of their age in the cache, the oldest coming first. If cache_index is invalid, then this function returns None.
key_rank index ctxt key returns the number of cached value older than the given key; or, None if the key is not a cache key.
Cache helpers for RPCs
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`.
cache_size ctxt ~cache_index returns an overapproximation of the size of the cache. Returns None if cache_index is not a valid cache index.