From c8ab7ff14c36d000de6fd261b80d39c0b78384c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B9=E7=89=9B=E5=95=A4?= Date: Sat, 29 Jun 2024 15:23:14 +0800 Subject: [PATCH] modify scanner interval. (#273) --- explorer/src/service/error.rs | 8 +++++++- prismer/src/commands.rs | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/explorer/src/service/error.rs b/explorer/src/service/error.rs index 2e8f7b7..47af59f 100644 --- a/explorer/src/service/error.rs +++ b/explorer/src/service/error.rs @@ -1,5 +1,6 @@ use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; +use sqlx::Error::RowNotFound; use std::num::ParseFloatError; #[derive(Debug)] @@ -73,7 +74,12 @@ impl IntoResponse for ExplorerError { fn into_response(self) -> Response { let err_msg = match self { ExplorerError::Custom(e) => e, - ExplorerError::DBErr(e) => e.to_string(), + ExplorerError::DBErr(e) => { + if let RowNotFound = e { + return (StatusCode::NOT_FOUND, "not found").into_response(); + } + e.to_string() + } ExplorerError::IOErr(e) => e.to_string(), ExplorerError::TomlDeErr(e) => e.to_string(), ExplorerError::HexErr(e) => e.to_string(), diff --git a/prismer/src/commands.rs b/prismer/src/commands.rs index 1889248..61be177 100644 --- a/prismer/src/commands.rs +++ b/prismer/src/commands.rs @@ -16,7 +16,6 @@ use crate::{Error, Result}; const DEFAULT_TIMEOUT_SECS: u64 = 32; const DEFAULT_RETIES: usize = 3; const DEFAULT_CONCURRENCY: usize = 8; -//const DEFAULT_INTERVAL: Duration = Duration::from_secs(15); /// load block at specific height. #[derive(Parser, Debug)] @@ -141,7 +140,7 @@ impl Subscribe { let itv = env::var("INTERVAL") .ok() - .unwrap_or(String::from("15")) + .unwrap_or("10".to_string()) .parse::()?; let interval = Duration::from_secs(itv); info!("interval={:?}", interval);