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>We will need to request a snapshot for components/contracts that we did not emit as snapshot for yet but are relevant now, e.g. because min tvl threshold exceeded.
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)
pub fn process_entrypoints(&mut self, dci_update: &DCIUpdate)
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.
Auto Trait Implementations§
impl<R> Freeze for ComponentTracker<R>where
R: Freeze,
impl<R> RefUnwindSafe for ComponentTracker<R>where
R: RefUnwindSafe,
impl<R> Send for ComponentTracker<R>
impl<R> Sync for ComponentTracker<R>
impl<R> Unpin for ComponentTracker<R>where
R: Unpin,
impl<R> UnsafeUnpin for ComponentTracker<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for ComponentTracker<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more