Skip to content

Commit

Permalink
rename: fetch_genesis_storage_at -> fetch_storage_at
Browse files Browse the repository at this point in the history
  • Loading branch information
nanometerzhu committed May 30, 2024
1 parent d2232f0 commit 256b123
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions standalone/pherry/src/chain_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ pub async fn fetch_storage_changes(
/// Fetch the genesis storage.
pub async fn fetch_genesis_storage(api: &ParachainApi) -> Result<Vec<(Vec<u8>, Vec<u8>)>> {
let hash = Some(api.genesis_hash());
fetch_genesis_storage_at(api, hash).await
fetch_storage_at(api, hash).await
}

pub async fn fetch_genesis_storage_at(
pub async fn fetch_storage_at(
api: &ParachainApi,
hash: Option<sp_core::H256>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>> {
let hash = match hash {
Some(h) => h,
None => api.rpc().finalized_head().await?,
};
let response = api
.extra_rpc()
.storage_pairs(StorageKey(vec![]), hash)
.storage_pairs(StorageKey(vec![]), Some(hash))
.await?;
let storage = response.into_iter().map(|(k, v)| (k.0, v.0)).collect();
Ok(storage)
Expand Down Expand Up @@ -139,7 +143,7 @@ pub async fn search_suitable_genesis_for_worker(
.await
.context("Failed to resolve block number")?
.ok_or_else(|| anyhow::anyhow!("Block number {block} not found"))?;
let genesis = fetch_genesis_storage_at(api, Some(block_hash))
let genesis = fetch_storage_at(api, Some(block_hash))
.await
.context("Failed to fetch genesis storage")?;
Ok((block, genesis))
Expand Down
2 changes: 1 addition & 1 deletion standalone/prb/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl Processor {
let dcap_init_runtime_request = dsm.clone().get_init_runtime_default_request(Some(phala_types::AttestationProvider::Dcap)).await.unwrap();

let mut storage = Storage::default();
let pairs = pherry::chain_client::fetch_genesis_storage_at(
let pairs = pherry::chain_client::fetch_storage_at(
&use_parachain_api!(dsm, false).unwrap(),
None,
).await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion standalone/prb/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ async fn send_storage_changes(
.await
.context("Failed to resolve block number")?
.ok_or_else(|| anyhow!("Block number {to} not found"))?;
let pairs = pherry::chain_client::fetch_genesis_storage_at(&para_api, Some(to_hash)).await?;
let pairs = pherry::chain_client::fetch_storage_at(&para_api, Some(to_hash)).await?;
let _ = bus.send_processor_event(ProcessorEvent::ReceivedParaChainState(pairs));
info!("Sent chain state for #{} to processor for chain state cache.", to);
}
Expand Down

0 comments on commit 256b123

Please sign in to comment.