Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fc1e148

Browse files
committedMar 10, 2025·
Add new HTTP endpoint that returns total supply as of given state root
1 parent 8d1abce commit fc1e148

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
@@ -4457,6 +4457,23 @@ pub fn serve<T: BeaconChainTypes>(
44574457
},
44584458
);
44594459

4460+
// GET lighthouse/supply/{state_root}
4461+
let get_lighthouse_supply = warp::path("lighthouse")
4462+
.and(warp::path("supply"))
4463+
.and(warp::path::param::<StateId>())
4464+
.and(warp::path::end())
4465+
.and(task_spawner_filter.clone())
4466+
.and(chain_filter.clone())
4467+
.then(|state_id: StateId, task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
4468+
task_spawner.blocking_json_task(Priority::P1, move || {
4469+
state_id
4470+
.map_state_and_execution_optimistic_and_finalized(&chain, |state, execution_optimistic, finalized| {
4471+
Ok((state.balances().iter().sum::<u64>(), execution_optimistic, finalized))
4472+
})
4473+
.map(api_types::GenericResponse::from)
4474+
})
4475+
});
4476+
44604477
// GET lighthouse/analysis/attestation_performance/{index}
44614478
let get_lighthouse_attestation_performance = warp::path("lighthouse")
44624479
.and(warp::path("analysis"))
@@ -4725,6 +4742,7 @@ pub fn serve<T: BeaconChainTypes>(
47254742
.uor(get_lighthouse_staking)
47264743
.uor(get_lighthouse_database_info)
47274744
.uor(get_lighthouse_block_rewards)
4745+
.uor(get_lighthouse_supply)
47284746
.uor(get_lighthouse_attestation_performance)
47294747
.uor(get_beacon_light_client_optimistic_update)
47304748
.uor(get_beacon_light_client_finality_update)

0 commit comments

Comments
 (0)