Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed May 27, 2024
1 parent 81147e1 commit 9e5740c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions programs/validator-history/idl/validator_history.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@
{
"code": 6001,
"name": "InvalidEpochCredits",
"msg": "Invalid epoch credits, credits must be greater than previous credits"
"msg": "Invalid epoch credits, credits must exist and each value must be greater than previous credits"
},
{
"code": 6002,
Expand All @@ -928,7 +928,7 @@
{
"code": 6006,
"name": "NotEnoughVotingHistory",
"msg": "Not enough voting history to create account. Minimum 10 epochs required"
"msg": "Not enough voting history to create account. Minimum 5 epochs required"
},
{
"code": 6007,
Expand Down
2 changes: 1 addition & 1 deletion programs/validator-history/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub enum ValidatorHistoryError {
#[msg("Account already reached proper size, no more allocations allowed")]
AccountFullySized,
#[msg(
"Invalid epoch credits, credits exist and each value must be greater than previous credits"
"Invalid epoch credits, credits must exist and each value must be greater than previous credits"
)]
InvalidEpochCredits,
#[msg("Epoch is out of range of history")]
Expand Down
5 changes: 3 additions & 2 deletions programs/validator-history/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,13 @@ impl ValidatorHistory {
}));

for (entry_is_some, epoch) in entries.iter().zip(start_epoch as u16..=end_epoch) {
if !*entry_is_some && epoch_credits_map.get(&epoch).is_some() {
if !*entry_is_some && epoch_credits_map.contains_key(&epoch) {
// Inserts blank entry that will have credits copied to it later
let entry = ValidatorHistoryEntry {
epoch,
..ValidatorHistoryEntry::default()
};
// If entry cannot be inserted, skips
// Skips if epoch is out of range or duplicate
self.history.insert(entry, epoch).unwrap_or_default();
}
}
Expand Down

0 comments on commit 9e5740c

Please sign in to comment.