From 83bda1e7f0f9b82cce5446c594adaa6d5091d4bd Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 12 Feb 2019 17:58:51 +1100 Subject: [PATCH 1/2] Minor modification to reduce lines of code Replaces the counter with the index of the loop. It is functionally the same, but uses two less lines of code. --- specs/core/0_beacon-chain.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 0f020be531..62582ce080 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2030,10 +2030,8 @@ def process_penalties_and_exits(state: BeaconState) -> None: eligible_indices = filter(eligible, all_indices) # Sort in order of exit epoch, and validators that exit within the same epoch exit in order of validator index sorted_indices = sorted(eligible_indices, key=lambda index: state.validator_registry[index].exit_epoch) - withdrawn_so_far = 0 - for index in sorted_indices: + for withdrawn_so_far, index in enumerate(sorted_indices): prepare_validator_for_withdrawal(state, index) - withdrawn_so_far += 1 if withdrawn_so_far >= MAX_WITHDRAWALS_PER_EPOCH: break ``` From 280d6081c26f820f2e7f8a86743221b28dd0b5ea Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 12 Feb 2019 11:03:57 +0000 Subject: [PATCH 2/2] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 62582ce080..11f5007ee0 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2031,9 +2031,9 @@ def process_penalties_and_exits(state: BeaconState) -> None: # Sort in order of exit epoch, and validators that exit within the same epoch exit in order of validator index sorted_indices = sorted(eligible_indices, key=lambda index: state.validator_registry[index].exit_epoch) for withdrawn_so_far, index in enumerate(sorted_indices): - prepare_validator_for_withdrawal(state, index) if withdrawn_so_far >= MAX_WITHDRAWALS_PER_EPOCH: break + prepare_validator_for_withdrawal(state, index) ``` #### Final updates