Skip to content

Commit

Permalink
improvement according github comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii committed Oct 24, 2024
1 parent fbdc51f commit e10feb8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
15 changes: 0 additions & 15 deletions configuration/src/default_env_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,9 @@ tracked_changes = "${TRACKED_CHANGES}"
### Lake framework configuration
[lake_config]
<<<<<<< HEAD:configuration/src/default_env_configs.rs
## Lake framework AWS access key id
aws_access_key_id = "${AWS_ACCESS_KEY_ID}"
## Lake framework AWS secret access key
aws_secret_access_key = "${AWS_SECRET_ACCESS_KEY}"
## Lake framework AWS default region
aws_default_region = "${AWS_DEFAULT_REGION}"
## Lake framework bucket name
aws_bucket_name = "${AWS_BUCKET_NAME}"
=======
# Number of threads to use for fetching data from fatnear
# Default: 2 * available threads
#num_threads = 8
>>>>>>> 6909c65 (migrate to fastnear):configuration/example.config.toml
## Transaction details are stored in the Google Cloud Storage
[tx_details_storage]
Expand Down
5 changes: 5 additions & 0 deletions rpc-server/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ lazy_static! {
"Optimistic updating status. 0: working, 1: not working",
).unwrap();

pub(crate) static ref CURRENT_PROTOCOL_VERSION: IntGauge = try_create_int_gauge(
"current_protocol_version",
"Current protocol version",
).unwrap();

pub(crate) static ref LEGACY_DATABASE_TX_DETAILS: IntCounterVec = register_int_counter_vec(
"legacy_database_tx_details",
"Total number of calls to the legacy database for transaction details",
Expand Down
17 changes: 9 additions & 8 deletions rpc-server/src/modules/blocks/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use near_primitives::views::StateChangeValueView;

use crate::config::ServerContext;
use crate::modules::blocks::utils::{
check_block_height, fetch_block_from_cache_or_get, fetch_chunk_from_fastnear, is_matching_change,
check_block_height, fetch_block_from_cache_or_get, fetch_chunk_from_fastnear,
is_matching_change,
};

/// `block` rpc method implementation
Expand Down Expand Up @@ -363,13 +364,13 @@ pub async fn fetch_block(
&data.fastnear_client,
block_height,
)
.await
.map_err(|err| {
tracing::error!("Failed to fetch block from fastnear: {}", err);
near_jsonrpc::primitives::types::blocks::RpcBlockError::UnknownBlock {
error_message: format!("BLOCK HEIGHT: {:?}", block_height),
}
})?
.await
.map_err(|err| {
tracing::error!("Failed to fetch block from fastnear: {}", err);
near_jsonrpc::primitives::types::blocks::RpcBlockError::UnknownBlock {
error_message: format!("BLOCK HEIGHT: {:?}", block_height),
}
})?
};
Ok(near_jsonrpc::primitives::types::blocks::RpcBlockResponse { block_view })
}
Expand Down
6 changes: 4 additions & 2 deletions rpc-server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ pub async fn get_current_protocol_version(
near_rpc_client: &JsonRpcClient,
) -> anyhow::Result<near_primitives::version::ProtocolVersion> {
let params = near_jsonrpc_client::methods::status::RpcStatusRequest;
Ok(near_rpc_client.call(params, None).await?.protocol_version)
let protocol_version = near_rpc_client.call(params, None).await?.protocol_version;
crate::metrics::CURRENT_PROTOCOL_VERSION.set(protocol_version as i64);
Ok(protocol_version)
}

async fn handle_streamer_message(
Expand Down Expand Up @@ -205,7 +207,7 @@ pub async fn update_final_block_regularly(
)
.await
{
tracing::error!("Error to handle_streamer_message: {:?}", err);
tracing::error!("Error in fn handle_streamer_message(): {:?}", err);
};
// Sleep for 500ms before the next iteration
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
Expand Down

0 comments on commit e10feb8

Please sign in to comment.