diff --git a/explorer/src/service/v1/block.rs b/explorer/src/service/v1/block.rs index 230b9d0..21dd112 100644 --- a/explorer/src/service/v1/block.rs +++ b/explorer/src/service/v1/block.rs @@ -6,7 +6,7 @@ use poem_openapi::param::Query; use poem_openapi::{param::Path, payload::Json, ApiResponse, Object}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use sqlx::types::chrono::NaiveDateTime; +use sqlx::types::chrono::DateTime; use sqlx::{Error, Row}; use std::ops::Add; @@ -285,13 +285,13 @@ pub async fn get_blocks( if let Some(start_time) = start_time.0 { params.push(format!( " time >= '{}' ", - NaiveDateTime::from_timestamp_opt(start_time, 0).unwrap() + DateTime::from_timestamp(start_time, 0).unwrap() )); } if let Some(end_time) = end_time.0 { params.push(format!( " time <= '{}' ", - NaiveDateTime::from_timestamp_opt(end_time, 0).unwrap() + DateTime::from_timestamp(end_time, 0).unwrap() )); } let page = page.0.unwrap_or(1); diff --git a/explorer/src/service/v1/chain.rs b/explorer/src/service/v1/chain.rs index fdc004c..cce1434 100644 --- a/explorer/src/service/v1/chain.rs +++ b/explorer/src/service/v1/chain.rs @@ -217,12 +217,12 @@ pub async fn statistics(api: &Api, ty: Query>) -> Result={}", ty, - start_time.timestamp() + start_time.and_utc().timestamp() ) } else { format!( "SELECT COUNT(*) as cnt FROM transaction WHERE timestamp>={}", - start_time.timestamp() + start_time.and_utc().timestamp() ) }; let row = sqlx::query(sql_str.as_str()).fetch_one(&mut conn).await?; diff --git a/explorer/src/service/v1/price.rs b/explorer/src/service/v1/price.rs index a4882d9..8b67fd6 100644 --- a/explorer/src/service/v1/price.rs +++ b/explorer/src/service/v1/price.rs @@ -1,6 +1,5 @@ use crate::service::api::Api; use anyhow::Result; -use log::error; use poem_openapi::param::{Path, Query}; use poem_openapi::types::Type; use poem_openapi::{payload::Json, ApiResponse, Object}; @@ -114,8 +113,7 @@ pub async fn simple_price( ids.0, vs_currencies.0 ); let resp1 = reqwest::get(url).await; - if let Err(e) = resp1 { - error!("Get FRA price: {}", e.to_string()); + if resp1.is_err() { let fra_price = get_fra_price(api).await?; return Ok(SimplePriceResponse::Ok(Json(SimplePriceResult { code: 200, @@ -125,8 +123,7 @@ pub async fn simple_price( } let resp2 = resp1?.json::().await; - if let Err(e) = resp2 { - error!("Parse FRA price: {}", e.to_string()); + if resp2.is_err() { let fra_price = get_fra_price(api).await?; return Ok(SimplePriceResponse::Ok(Json(SimplePriceResult { code: 200, @@ -172,8 +169,7 @@ pub async fn market_chart( url = format!("https://api.coingecko.com/api/v3/coins/{}/market_chart?vs_currency={}&days={}&interval={}", id.0, vs_currency.0, days.0, itv); } let resp1 = reqwest::get(url).await; - if let Err(e) = resp1 { - error!("Get FRA market error: {:?}", e); + if resp1.is_err() { let fmc = get_fra_market(api).await?; return Ok(MarketChartResponse::Ok(Json(MarketChartResult { code: 200, @@ -182,8 +178,7 @@ pub async fn market_chart( }))); } let resp2 = resp1?.json::().await; - if let Err(e) = resp2 { - error!("Parse FRA market cap error: {:?}", e); + if resp2.is_err() { let fmc = get_fra_market(api).await?; return Ok(MarketChartResponse::Ok(Json(MarketChartResult { code: 200, diff --git a/explorer/src/service/v1/validator.rs b/explorer/src/service/v1/validator.rs index 2ee3153..7d2002a 100644 --- a/explorer/src/service/v1/validator.rs +++ b/explorer/src/service/v1/validator.rs @@ -7,7 +7,7 @@ use poem_openapi::param::{Path, Query}; use poem_openapi::{payload::Json, ApiResponse, Object}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use sqlx::types::chrono::{Local, NaiveDateTime}; +use sqlx::types::chrono::{DateTime, Local}; use sqlx::Row; #[derive(ApiResponse)] @@ -465,6 +465,7 @@ pub async fn validator_signed_count( .date_naive() .and_hms_opt(0, 0, 0) .unwrap() + .and_utc() .timestamp() - (page - 1) * page_size * day_secs; @@ -472,8 +473,8 @@ pub async fn validator_signed_count( for i in 0..page_size { let start_secs = nt - i * day_secs; let end_secs = nt - i * day_secs + day_secs; - let start_time = NaiveDateTime::from_timestamp_opt(start_secs, 0).unwrap(); - let end_time = NaiveDateTime::from_timestamp_opt(end_secs, 0).unwrap(); + let start_time = DateTime::from_timestamp(start_secs, 0).unwrap(); + let end_time = DateTime::from_timestamp(end_secs, 0).unwrap(); let sql_block_cnt = format!( "SELECT count(*) as cnt FROM block WHERE time>='{start_time}' AND time<'{end_time}'" diff --git a/explorer/src/service/v2/other.rs b/explorer/src/service/v2/other.rs index 51783b5..7679757 100644 --- a/explorer/src/service/v2/other.rs +++ b/explorer/src/service/v2/other.rs @@ -61,7 +61,7 @@ pub async fn v2_statistics(api: &Api, ty: Query>) -> Result={}", - start_time.timestamp() + start_time.and_utc().timestamp() ); } _ => { @@ -69,7 +69,7 @@ pub async fn v2_statistics(api: &Api, ty: Query>) -> Result={}", - start_time.timestamp() + start_time.and_utc().timestamp() ); } } @@ -110,7 +110,7 @@ pub async fn v2_statistics(api: &Api, ty: Query>) -> Result={}", - start_time.timestamp() + start_time.and_utc().timestamp() ); let row_daily = sqlx::query(sql_daily_txs.as_str()) .fetch_one(&mut conn) diff --git a/prismer/src/rpc.rs b/prismer/src/rpc.rs index 3da1783..4b3223b 100644 --- a/prismer/src/rpc.rs +++ b/prismer/src/rpc.rs @@ -282,7 +282,7 @@ impl RPCCaller { amount: amount.to_string(), decimal: decimal as i64, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), value: result.clone(), }); diff --git a/scanner/src/rpc.rs b/scanner/src/rpc.rs index c671c86..1a421d1 100644 --- a/scanner/src/rpc.rs +++ b/scanner/src/rpc.rs @@ -234,7 +234,7 @@ impl RPCCaller { native_addrs.push(Address { tx: tx_hash.clone(), address: to, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), }); } sender = "".to_string(); @@ -279,7 +279,7 @@ impl RPCCaller { tx_hash: tx_hash.clone(), block_hash: block_hash.clone(), height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), code: tx.tx_result.code, ty: FindoraTxType::Evm as i32, ty_sub, @@ -300,7 +300,7 @@ impl RPCCaller { evm_addrs.push(Address { tx: tx_hash.clone(), address: a, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), }); } } @@ -331,7 +331,7 @@ impl RPCCaller { evm_addrs.push(Address { tx: tx_hash.clone(), address: receiver.clone(), - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), }); sender = signer.clone(); ty_sub = FindoraTxType::NativeToEVM as i32; @@ -343,7 +343,7 @@ impl RPCCaller { asset, amount: opt.convert_account.value, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), content: op_copy, }); } else if op_str.contains("UnDelegation") { @@ -375,7 +375,7 @@ impl RPCCaller { target_validator, new_delegator, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), content: op_copy, }); } else if op_str.contains("Delegation") { @@ -395,7 +395,7 @@ impl RPCCaller { validator: opt.delegation.body.validator, new_validator, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), content: op_copy, }); } else if op_str.contains("Claim") { @@ -411,7 +411,7 @@ impl RPCCaller { sender: signer, amount: opt.claim.body.amount.unwrap_or(0), height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), content: op_copy, }); } else if op_str.contains("DefineAsset") { @@ -432,7 +432,7 @@ impl RPCCaller { block_hash: block_hash.clone(), issuer, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), issued: 0, content: op_copy, }); @@ -452,7 +452,7 @@ impl RPCCaller { block_hash: block_hash.clone(), issuer, height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), issued: 1, content: op_copy, }); @@ -541,7 +541,7 @@ impl RPCCaller { tx_hash: tx_hash.clone(), block_hash: block_hash.clone(), height, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), code: tx.tx_result.code, ty: FindoraTxType::Native as i32, ty_sub, @@ -562,7 +562,7 @@ impl RPCCaller { native_addrs.push(Address { tx: tx_hash.clone(), address: a, - timestamp: timestamp.timestamp(), + timestamp: timestamp.and_utc().timestamp(), }); } }