-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactors the OnStakingUpdate
trait
#2839
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
title: "Refactors `OnStakingUpdate` trait" | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: Refactors the `sp_staking:OnStakingUpdate` to make event inputs more explicit. | ||
|
||
crates: | ||
- name: "sp-staking" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,19 +100,29 @@ pub trait OnStakingUpdate<AccountId, Balance> { | |
/// | ||
/// This is effectively any changes to the bond amount, such as bonding more funds, and | ||
/// unbonding. | ||
fn on_stake_update(_who: &AccountId, _prev_stake: Option<Stake<Balance>>) {} | ||
fn on_stake_update( | ||
_who: &AccountId, | ||
_prev_stake: Option<Stake<Balance>>, | ||
_stake: Stake<Balance>, | ||
) { | ||
} | ||
|
||
/// Fired when someone sets their intention to nominate. | ||
/// | ||
/// This should never be fired for existing nominators. | ||
fn on_nominator_add(_who: &AccountId) {} | ||
fn on_nominator_add(_who: &AccountId, _nominations: Vec<AccountId>) {} | ||
|
||
/// Fired when an existing nominator updates their nominations. | ||
/// | ||
/// Note that this is not fired when a nominator changes their stake. For that, | ||
/// `on_stake_update` should be used, followed by querying whether `who` was a validator or a | ||
/// nominator. | ||
fn on_nominator_update(_who: &AccountId, _prev_nominations: Vec<AccountId>) {} | ||
fn on_nominator_update( | ||
_who: &AccountId, | ||
_prev_nominations: Vec<AccountId>, | ||
_nominations: Vec<AccountId>, | ||
) { | ||
} | ||
|
||
/// Fired when someone removes their intention to nominate, either due to chill or validating. | ||
/// | ||
|
@@ -123,15 +133,15 @@ pub trait OnStakingUpdate<AccountId, Balance> { | |
/// Fired when someone sets their intention to validate. | ||
/// | ||
/// Note validator preference changes are not communicated, but could be added if needed. | ||
fn on_validator_add(_who: &AccountId) {} | ||
fn on_validator_add(_who: &AccountId, _self_stake: Option<Stake<Balance>>) {} | ||
|
||
/// Fired when an existing validator updates their preferences. | ||
/// | ||
/// Note validator preference changes are not communicated, but could be added if needed. | ||
fn on_validator_update(_who: &AccountId) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this also need old and new self stake params? |
||
|
||
/// Fired when someone removes their intention to validate, either due to chill or nominating. | ||
fn on_validator_remove(_who: &AccountId) {} | ||
fn on_validator_remove(_who: &AccountId, _self_stake: Option<Stake<Balance>>) {} | ||
|
||
/// Fired when someone is fully unstaked. | ||
fn on_unstake(_who: &AccountId) {} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have both
_prev_stake
and_stake
as same type? EitherStake<Balance>
orOption<Stake<Balance>>
. IfStake<Balance>
, we can pass a zero value.