pub trait UpdateDataSource<Types: NodeType>: UpdateAvailabilityData<Types> {
// Required method
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event<Types>,
) -> Pin<Box<dyn Future<Output = Result<(), u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
An extension trait for types which implement the update trait for each API module.
If a type implements UpdateAvailabilityData and UpdateStatusData, then it can be fully kept up to date through two interfaces:
- populate_metrics, to get a handle for populating the status metrics, which should be used when initializing a SystemContextHandle
- update, provided by this extension trait, to update the query state when a new HotShot event is emitted
Required Methods§
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event<Types>,
) -> Pin<Box<dyn Future<Output = Result<(), u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 Event<Types>,
) -> Pin<Box<dyn Future<Output = Result<(), u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update query state based on a new consensus event.
The caller is responsible for authenticating event
. This function does not perform any
authentication, and if given an invalid event
(one which does not follow from the latest
known state of the ledger) it may panic or silently accept the invalid event
. This allows
the best possible performance in the case where the query service and the HotShot instance
are running in the same process (and thus the event stream, directly from HotShot) is
trusted.
If you want to update the data source with an untrusted event, for example one received from a peer over the network, you must authenticate it first.
§Returns
If all provided data is successfully inserted into the database, returns Ok(())
. If any
error occurred, the error is logged, and the return value is the height of the first leaf
which failed to be inserted.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.