pub struct ComponentTracker<R: RPCClient> {
pub components: HashMap<ComponentId, ProtocolComponent>,
pub contracts: HashSet<Address>,
/* private fields */
}Expand description
Helper struct to determine which components and contracts are being tracked atm.
Fields§
§components: HashMap<ComponentId, ProtocolComponent>§contracts: HashSet<Address>Derived from tracked components. We need this if subscribed to a vm extractor because updates are emitted on a contract level instead of a component level.
Implementations§
Source§impl<R> ComponentTracker<R>where
R: RPCClient,
impl<R> ComponentTracker<R>where
R: RPCClient,
pub fn new( chain: Chain, protocol_system: &str, filter: ComponentFilter, rpc: R, ) -> Self
Sourcepub async fn initialise_components(&mut self) -> Result<(), RPCError>
pub async fn initialise_components(&mut self) -> Result<(), RPCError>
Retrieves all components that belong to the system we are streaming that have sufficient tvl. Also detects which contracts are relevant for simulating on those components.
Sourcepub async fn start_tracking(
&mut self,
new_components: &[&ComponentId],
) -> Result<(), RPCError>
pub async fn start_tracking( &mut self, new_components: &[&ComponentId], ) -> Result<(), RPCError>
Add new components to be tracked
Sourcepub fn stop_tracking<'a, I: IntoIterator<Item = &'a ComponentId> + Debug>(
&mut self,
to_remove: I,
) -> HashMap<ComponentId, ProtocolComponent>
pub fn stop_tracking<'a, I: IntoIterator<Item = &'a ComponentId> + Debug>( &mut self, to_remove: I, ) -> HashMap<ComponentId, ProtocolComponent>
Stop tracking components
Sourcepub fn process_entrypoints(
&mut self,
dci_update: &DCIUpdate,
) -> Result<(), RPCError>
pub fn process_entrypoints( &mut self, dci_update: &DCIUpdate, ) -> Result<(), RPCError>
Updates the tracked entrypoints and contracts based on the given DCI data.
Sourcepub fn get_contracts_by_component<'a, I: IntoIterator<Item = &'a String>>(
&self,
ids: I,
) -> HashSet<Address>
pub fn get_contracts_by_component<'a, I: IntoIterator<Item = &'a String>>( &self, ids: I, ) -> HashSet<Address>
Get related contracts for the given component ids. Assumes that the components are already
tracked, either by calling start_tracking or initialise_components.
§Arguments
ids- A vector of component IDs to get the contracts for.
§Returns
A HashSet of contract IDs. Components that are not tracked will be logged and skipped.
pub fn get_tracked_component_ids(&self) -> Vec<ComponentId> ⓘ
Sourcepub fn filter_updated_components(
&self,
deltas: &BlockChanges,
) -> (Vec<ComponentId>, Vec<ComponentId>)
pub fn filter_updated_components( &self, deltas: &BlockChanges, ) -> (Vec<ComponentId>, Vec<ComponentId>)
Given BlockChanges, filter out components that are no longer relevant and return the components that need to be added or removed.