Skip to content

Commit fdac322

Browse files
committed
Add new HTTP endpoint that returns total supply as of given state root
1 parent 3f6c11d commit fdac322

File tree

1 file changed

+18
-0
lines changed
  • beacon_node/http_api/src

1 file changed

+18
-0
lines changed

beacon_node/http_api/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,6 +4448,23 @@ pub fn serve<T: BeaconChainTypes>(
44484448
})
44494449
});
44504450

4451+
// GET lighthouse/supply/{state_root}
4452+
let get_lighthouse_supply = warp::path("lighthouse")
4453+
.and(warp::path("supply"))
4454+
.and(warp::path::param::<StateId>())
4455+
.and(warp::path::end())
4456+
.and(task_spawner_filter.clone())
4457+
.and(chain_filter.clone())
4458+
.then(|state_id: StateId, task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
4459+
task_spawner.blocking_json_task(Priority::P1, move || {
4460+
state_id
4461+
.map_state_and_execution_optimistic_and_finalized(&chain, |state, execution_optimistic, finalized| {
4462+
Ok((state.balances().iter().sum::<u64>(), execution_optimistic, finalized))
4463+
})
4464+
.map(api_types::GenericResponse::from)
4465+
})
4466+
});
4467+
44514468
// GET lighthouse/analysis/attestation_performance/{index}
44524469
let get_lighthouse_attestation_performance = warp::path("lighthouse")
44534470
.and(warp::path("analysis"))
@@ -4720,6 +4737,7 @@ pub fn serve<T: BeaconChainTypes>(
47204737
.uor(get_lighthouse_staking)
47214738
.uor(get_lighthouse_database_info)
47224739
.uor(get_lighthouse_block_rewards)
4740+
.uor(get_lighthouse_supply)
47234741
.uor(get_lighthouse_attestation_performance)
47244742
.uor(get_beacon_light_client_optimistic_update)
47254743
.uor(get_beacon_light_client_finality_update)

0 commit comments

Comments
 (0)