Skip to content

Commit 40dc316

Browse files
committed
chore: change name more descriptive
1 parent 93de04b commit 40dc316

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

common/src/queries/epochs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum EpochsStateQuery {
1313
GetEpochStakeDistributionByPool { epoch_number: u64 },
1414
GetEpochBlockDistribution { epoch_number: u64 },
1515
GetEpochBlockDistributionByPool { epoch_number: u64 },
16-
GetBlocksMintedByPool { vrf_key_hash: KeyHash },
16+
GetLatestEpochBlocksMintedByPool { vrf_key_hash: KeyHash },
1717
}
1818

1919
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@@ -26,7 +26,7 @@ pub enum EpochsStateQueryResponse {
2626
EpochStakeDistributionByPool(EpochStakeDistributionByPool),
2727
EpochBlockDistribution(EpochBlockDistribution),
2828
EpochBlockDistributionByPool(EpochBlockDistributionByPool),
29-
BlocksMintedByPool(u64),
29+
LatestEpochBlocksMintedByPool(u64),
3030

3131
NotFound,
3232
Error(String),

modules/epochs_state/src/epochs_state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ impl EpochsState {
227227
}
228228
}
229229

230-
EpochsStateQuery::GetBlocksMintedByPool { vrf_key_hash } => {
231-
EpochsStateQueryResponse::BlocksMintedByPool(
232-
state.get_blocks_minted_by_pool(vrf_key_hash),
230+
EpochsStateQuery::GetLatestEpochBlocksMintedByPool { vrf_key_hash } => {
231+
EpochsStateQueryResponse::LatestEpochBlocksMintedByPool(
232+
state.get_latest_epoch_blocks_minted_by_pool(vrf_key_hash),
233233
)
234234
}
235235

modules/epochs_state/src/state.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl State {
8181
}
8282
}
8383

84-
pub fn get_blocks_minted_by_pool(&self, vrf_key_hash: &KeyHash) -> u64 {
84+
pub fn get_latest_epoch_blocks_minted_by_pool(&self, vrf_key_hash: &KeyHash) -> u64 {
8585
self.blocks_minted.get(vrf_key_hash).map(|v| *v as u64).unwrap_or(0)
8686
}
8787
}
@@ -172,7 +172,7 @@ mod tests {
172172
Some(2)
173173
);
174174

175-
let blocks_minted = state.get_blocks_minted_by_pool(&keyhash(b"vrf_2"));
175+
let blocks_minted = state.get_latest_epoch_blocks_minted_by_pool(&keyhash(b"vrf_2"));
176176
assert_eq!(blocks_minted, 2);
177177
}
178178

@@ -212,7 +212,7 @@ mod tests {
212212
assert_eq!(state.epoch_fees, 0);
213213
assert!(state.blocks_minted.is_empty());
214214

215-
let blocks_minted = state.get_blocks_minted_by_pool(&keyhash(b"vrf_1"));
215+
let blocks_minted = state.get_latest_epoch_blocks_minted_by_pool(&keyhash(b"vrf_1"));
216216
assert_eq!(blocks_minted, 0);
217217
}
218218

@@ -232,15 +232,24 @@ mod tests {
232232
block.number += 1;
233233
state.handle_mint(&block, Some(b"vrf_1"));
234234
state.handle_fees(&block, 123);
235-
assert_eq!(state.get_blocks_minted_by_pool(&keyhash(b"vrf_1")), 2);
235+
assert_eq!(
236+
state.get_latest_epoch_blocks_minted_by_pool(&keyhash(b"vrf_1")),
237+
2
238+
);
236239
history.lock().await.commit(block.number, state);
237240

238241
block = make_rolled_back_block(0);
239242
let mut state = history.lock().await.get_rolled_back_state(block.number);
240243
state.handle_mint(&block, Some(b"vrf_2"));
241244
state.handle_fees(&block, 123);
242-
assert_eq!(state.get_blocks_minted_by_pool(&keyhash(b"vrf_1")), 0);
243-
assert_eq!(state.get_blocks_minted_by_pool(&keyhash(b"vrf_2")), 1);
245+
assert_eq!(
246+
state.get_latest_epoch_blocks_minted_by_pool(&keyhash(b"vrf_1")),
247+
0
248+
);
249+
assert_eq!(
250+
state.get_latest_epoch_blocks_minted_by_pool(&keyhash(b"vrf_2")),
251+
1
252+
);
244253
history.lock().await.commit(block.number, state);
245254
}
246255
}

modules/rest_blockfrost/src/handlers/pools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ async fn handle_pools_spo_blockfrost(
622622

623623
// Query blocks_minted from epochs_state
624624
let epoch_blocks_minted_msg = Arc::new(Message::StateQuery(StateQuery::Epochs(
625-
EpochsStateQuery::GetBlocksMintedByPool {
625+
EpochsStateQuery::GetLatestEpochBlocksMintedByPool {
626626
vrf_key_hash: pool_info.vrf_key_hash.clone(),
627627
},
628628
)));
@@ -632,7 +632,7 @@ async fn handle_pools_spo_blockfrost(
632632
epoch_blocks_minted_msg,
633633
|message| match message {
634634
Message::StateQueryResponse(StateQueryResponse::Epochs(
635-
EpochsStateQueryResponse::BlocksMintedByPool(blocks_minted),
635+
EpochsStateQueryResponse::LatestEpochBlocksMintedByPool(blocks_minted),
636636
)) => Ok(blocks_minted),
637637
_ => Err(anyhow::anyhow!("Unexpected message type")),
638638
},

0 commit comments

Comments
 (0)