Skip to content

Commit

Permalink
imrovement
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii committed Oct 2, 2024
1 parent 46586a2 commit 0cab25d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
18 changes: 12 additions & 6 deletions configuration/src/configs/lake.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::configs::deserialize_optional_data_or_env;
use near_lake_framework::near_indexer_primitives::near_primitives;
use serde_derive::Deserialize;

use crate::configs::deserialize_optional_data_or_env;

#[derive(Debug, Clone)]
pub struct LakeConfig {
pub num_threads: Option<u64>,
Expand All @@ -12,13 +11,20 @@ impl LakeConfig {
pub async fn lake_config(
&self,
start_block_height: near_primitives::types::BlockHeight,
chain_id: crate::ChainId,
) -> anyhow::Result<near_lake_framework::FastNearConfig> {
let config_builder = near_lake_framework::FastNearConfigBuilder::default();
let mut config_builder = near_lake_framework::FastNearConfigBuilder::default();
match chain_id {
crate::ChainId::Mainnet => config_builder = config_builder.mainnet(),
// Testnet is the default chain for other chain_id
_ => config_builder = config_builder.testnet(),
};
if let Some(num_threads) = self.num_threads {
config_builder = config_builder.num_threads(num_threads);
};
Ok(config_builder
.mainnet()
.start_block_height(start_block_height)
.build()
.expect("Failed to build LakeConfig"))
.build()?)
}
}

Expand Down
3 changes: 2 additions & 1 deletion rpc-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl GenesisInfo {

#[derive(Clone)]
pub struct ServerContext {
/// Lake s3 client
/// Fastnear client
pub fastnear_client: near_lake_framework::fastnear_client::FastNearClient,
/// Database manager
pub db_manager: std::sync::Arc<Box<dyn database::ReaderDbManager + Sync + Send + 'static>>,
Expand Down Expand Up @@ -109,6 +109,7 @@ impl ServerContext {
.optimistic_cache_block()
.await
.block_height,
rpc_server_config.general.chain_id.clone(),
)
.await?
.client();
Expand Down
5 changes: 4 additions & 1 deletion state-indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ async fn main() -> anyhow::Result<()> {
)
.await?;

let lake_config = indexer_config.lake_config.lake_config(start_block_height).await?;
let lake_config = indexer_config
.lake_config
.lake_config(start_block_height, indexer_config.general.chain_id.clone())
.await?;
let (sender, stream) = near_lake_framework::streamer(lake_config);

// Initiate metrics http server
Expand Down
2 changes: 1 addition & 1 deletion tx-indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn main() -> anyhow::Result<()> {
tracing::info!(target: INDEXER, "Generating LakeConfig...");
let lake_config = indexer_config
.lake_config
.lake_config(start_block_height)
.lake_config(start_block_height, indexer_config.general.chain_id.clone())
.await?;

tracing::info!(target: INDEXER, "Creating cache storage...");
Expand Down

0 comments on commit 0cab25d

Please sign in to comment.