Skip to content

Commit

Permalink
Replace filter_map to parameterize RewardType filter expression
Browse files Browse the repository at this point in the history
  • Loading branch information
CriesofCarrots committed Jan 24, 2024
1 parent 6d5056e commit fde8522
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl JsonRpcRequestProcessor {
&self,
slot: Slot,
addresses: &[String],
reward_type_filter: &F,
reward_type_filter: F,
config: &RpcEpochConfig,
) -> Result<HashMap<String, (Reward, Slot)>>
where
Expand Down Expand Up @@ -593,6 +593,9 @@ impl JsonRpcRequestProcessor {
}

let bank = self.get_bank_with_config(slot_context)?;
let partitioned_epoch_reward_enabled = bank
.feature_set
.is_active(&feature_set::enable_partitioned_epoch_reward::id());

let first_confirmed_block_in_epoch = *self
.get_blocks_with_limit(first_slot_in_epoch, 1, config.commitment)
Expand All @@ -609,7 +612,7 @@ impl JsonRpcRequestProcessor {
self.get_reward_map(
first_confirmed_block_in_epoch,
&addresses,
&|reward_type| -> bool {
|reward_type| -> bool {
reward_type == RewardType::Voting
|| (!partitioned_epoch_reward_enabled && reward_type == RewardType::Staking)
},
Expand Down Expand Up @@ -668,7 +671,7 @@ impl JsonRpcRequestProcessor {
.get_reward_map(
slot,
addresses,
&|reward_type| -> bool { reward_type == RewardType::Staking },
|reward_type| -> bool { reward_type == RewardType::Staking },
&config,
)
.await?;
Expand Down

0 comments on commit fde8522

Please sign in to comment.