MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / query

Method query

fendermint/app/src/app.rs:696–739  ·  view source on GitHub ↗
(&self, request: request::Query)

Source from the content-addressed store, hash-verified

694 /// Query the application for data at the current or past height.
695 #[instrument(skip(self))]
696 async fn query(&self, request: request::Query) -> AbciResult<response::Query> {
697 let db = self.state_store_clone();
698 let height = FvmQueryHeight::from(request.height.value());
699 let (state_params, block_height) = self.state_params_at_height(height)?;
700
701 tracing::debug!(
702 query_height = request.height.value(),
703 block_height,
704 state_root = state_params.state_root.to_string(),
705 "running query"
706 );
707
708 // Don't run queries on the empty state, they won't work.
709 if !Self::can_query_state(block_height, &state_params) {
710 return Ok(invalid_query(
711 AppError::NotInitialized,
712 "The app hasn't been initialized yet.".to_owned(),
713 ));
714 }
715
716 let state = FvmQueryState::new(
717 db,
718 self.multi_engine.clone(),
719 block_height.try_into()?,
720 state_params,
721 self.check_state.clone(),
722 height == FvmQueryHeight::Pending,
723 )
724 .context("error creating query state")?;
725
726 let qry = (request.path, request.data.to_vec());
727
728 let (_, result) = self
729 .interpreter
730 .query(state, qry)
731 .await
732 .context("error running query")?;
733
734 let response = match result {
735 Err(e) => invalid_query(AppError::InvalidEncoding, e.description),
736 Ok(result) => to_query(result, block_height)?,
737 };
738 Ok(response)
739 }
740
741 /// Check the given transaction before putting it into the local mempool.
742 async fn check_tx(&self, request: request::CheckTx) -> AbciResult<response::CheckTx> {

Callers 1

run_subscriptionFunction · 0.45

Calls 7

invalid_queryFunction · 0.85
to_queryFunction · 0.85
contextMethod · 0.80
try_intoMethod · 0.80
to_vecMethod · 0.80
state_store_cloneMethod · 0.45

Tested by

no test coverage detected