Legend:
Library
Module
Module type
Parameter
Class
Class type
Tezos Shell - High-level API for the Gossip network and local storage.
It provides functions to query *static* resources such as blocks headers, operations, and functions to access dynamic resources such as heads and chains.
Several chains (mainchain, testchain, ...) can be managed independently. First a chain is activated using activate, which provides a chain_db from which it is possible to access resources. Eventually the chain is deactivated using deactivate.
Static resources are accessible via "Requester" modules (Block_header, Operation, Operations, Protocol). These modules act as read-through caches in front of the local storage State and the p2p layer. They centralize concurrent requests, and cache results in memory. They don't update State directly.
For instance, from a block_header hash, one can fetch the actual block header using Block_header.fetch, then the block operations with Operations.fetch.
The first call to activate t chain callbacks activates chain, creates a chain_db and sends a Get_current_branch chain_id message to all neighbors, where chain_id is the identifier of chain. This informs the neighbors that this node expects notifications for new heads/mempools. The given callbacks are given to the P2p_reader for each peer:
notify_branch peer locator is called when the P2p_reader receives the message Current_branch (chain, locator) from peer peer.
notify_head peer head is called when the P2p_reader receives the message Current_head (chain, head, mempool) from peer peer.
Disconnection peer is called when the P2p_reader receives the message Deactivate chain from peer peer or when the P2p_reader associated to peer is shutdown.
Subsequent calls simply return the existing chain_db.
deactivate chain_db sends a Deactivate chain_id message to all active neighbors for this chain. This notifies them that this node isn't interested in messages for this chain
Inject a prechecked block in the precheck_blocks memory table. This is to ensure the data availability of the operations once the block has been prechecked and advertised to our peers.
No need to remove the data explicitely of the precheck_blocks memory table. The table is handled as an LRU cache.