Skip to content

Commit

Permalink
execution-core: add Reward and RewardReason
Browse files Browse the repository at this point in the history
Allows for the host to call the stake contract with a vector of `Reward`
to rewards multiple accounts simultaneously.
  • Loading branch information
Eduardo Leegwater Simões committed Sep 6, 2024
1 parent f2b8fc0 commit d500a59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions execution-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ stake::{
StakeData;
StakeEvent;
Withdraw;
Reward;
RewardReason;
EPOCH;
STAKE_CONTRACT;
STAKE_WARNINGS;
Expand Down
27 changes: 27 additions & 0 deletions execution-core/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,30 @@ impl Serializable<STAKE_AMOUNT_SIZE> for StakeAmount {
buf
}
}

/// Used in a `reward` call to reward a given account with an amount of Dusk,
/// and emitted as an event, once a reward succeeds.
#[derive(Debug, Clone, PartialEq, Eq, Archive, Serialize, Deserialize)]
#[archive_attr(derive(CheckBytes))]
pub struct Reward {
/// The account to be rewarded.
pub account: BlsPublicKey,
/// The amount to reward.
pub value: u64,
/// The reason for the reward.
pub reason: RewardReason,
}

/// The reason that a reward is issued.
#[derive(Debug, Clone, PartialEq, Eq, Archive, Serialize, Deserialize)]
#[archive_attr(derive(CheckBytes))]
pub enum RewardReason {
/// The fixed amount awarded to a generator.
GeneratorFixed,
/// Extra amount awarded to a generator.
GeneratorExtra,
/// Amount awarded to a voter.
Voter,
/// Amount awarded for another reason, such as rewarding Dusk.
Other,
}

0 comments on commit d500a59

Please sign in to comment.