diff --git a/docs/api.md b/docs/api.md
index 3ea781e..656863e 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -11,7 +11,7 @@
## Chain
* [3.1 统计交易量](#3.1)
-
+* [3.2 地址总量](#3.2)
## Asset
* [4.1 获取资产信息](#4.1)
@@ -415,6 +415,18 @@
}
```
+
3.2 地址总量
+
+* `GET /api/chain/address/count`
+* 无参数
+* Request: `/api/chain/address/count`
+* Response:
+```json
+{
+ "count": 125003
+}
+```
+
4.1 获取资产信息
* `GET /api/assets`
diff --git a/explorer/src/main.rs b/explorer/src/main.rs
index 99da02c..414e83f 100644
--- a/explorer/src/main.rs
+++ b/explorer/src/main.rs
@@ -2,8 +2,8 @@ mod service;
use crate::service::api::Api;
use crate::service::v2::asset::get_assets;
use crate::service::v2::block::{
- get_block_by_hash, get_block_by_num, get_blocks, get_full_block_by_hash,
- get_full_block_by_height, get_simple_block_by_hash, get_simple_block_by_height,
+ get_block_by_hash, get_blocks, get_full_block_by_hash, get_full_block_by_height,
+ get_simple_block_by_hash, get_simple_block_by_height,
};
use crate::service::v2::claim::{get_claim_by_tx_hash, get_claims};
use crate::service::v2::delegation::{get_delegation_by_tx_hash, get_delegations};
@@ -56,20 +56,21 @@ async fn main() -> Result<()> {
.allow_headers(Any);
let addr = format!("{}:{}", config.server.addr, config.server.port);
let app = Router::new()
+ // chain
+ .route("/api/chain/address/count", get(get_address_count))
+ .route("/api/chain/statistics", get(get_statistics))
+ // block
.route("/api/block/hash/:hash", get(get_simple_block_by_hash))
.route("/api/block/full/hash/:hash", get(get_full_block_by_hash))
.route("/api/block/height/:num", get(get_simple_block_by_height))
.route("/api/block/full/height/:num", get(get_full_block_by_height))
- .route("/api/address/count", get(get_address_count))
- .route("/api/chain/statistics", get(get_statistics))
- .route("/api/txs/distribute", get(get_tx_distribute))
- .route("/api/chain/statistic", get(get_statistics))
- .route("/api/number/block", get(get_block_by_num))
.route("/api/block", get(get_block_by_hash))
.route("/api/blocks", get(get_blocks))
+ // tx
.route("/api/tx", get(get_tx_by_hash))
.route("/api/txs", get(get_txs))
- .route("/api/assets", get(get_assets))
+ .route("/api/txs/distribute", get(get_tx_distribute))
+ // staking
.route("/api/claim", get(get_claim_by_tx_hash))
.route("/api/claims", get(get_claims))
.route("/api/delegation", get(get_delegation_by_tx_hash))
@@ -80,6 +81,8 @@ async fn main() -> Result<()> {
.route("/api/n2es", get(get_n2e_txs))
.route("/api/e2n", get(get_e2n_by_tx_hash))
.route("/api/e2ns", get(get_e2n_txs))
+ // asset
+ .route("/api/assets", get(get_assets))
.layer(cors)
.with_state(app_state);
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
diff --git a/explorer/src/service/v2/block.rs b/explorer/src/service/v2/block.rs
index 9deefc0..f736c91 100644
--- a/explorer/src/service/v2/block.rs
+++ b/explorer/src/service/v2/block.rs
@@ -147,6 +147,7 @@ pub struct GetBlockByHeightParams {
pub num: i64,
}
+#[allow(dead_code)]
pub async fn get_block_by_num(
State(state): State>,
Query(params): Query,
diff --git a/explorer/src/service/v2/other.rs b/explorer/src/service/v2/other.rs
index cbe9f22..6fadfcb 100644
--- a/explorer/src/service/v2/other.rs
+++ b/explorer/src/service/v2/other.rs
@@ -181,7 +181,7 @@ pub struct AddressCountParams {
}
#[derive(Serialize, Deserialize)]
pub struct AddressCountResponse {
- address_count: i64,
+ count: i64,
}
pub async fn get_address_count(
@@ -223,6 +223,6 @@ pub async fn get_address_count(
let evm_count: i64 = row_evm.try_get("count").map_err(internal_error)?;
Ok(Json(AddressCountResponse {
- address_count: native_count + evm_count,
+ count: native_count + evm_count,
}))
}