Skip to content

Commit

Permalink
stake-contract: added slashed amount setter
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Feb 27, 2024
1 parent a96e5d9 commit 0942b25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contracts/stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ unsafe fn hard_slash(arg_len: u32) -> u32 {
STATE.hard_slash(&pk, value);
})
}

#[no_mangle]
unsafe fn set_slashed_amount(arg_len: u32) -> u32 {
rusk_abi::wrap_call(arg_len, |amount| {
assert_external_caller();
STATE.set_slashed_amount(amount)
})
}

/// Asserts the call is made via the transfer contract.
///
/// # Panics
Expand Down
5 changes: 5 additions & 0 deletions contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ impl StakeState {
}
}

/// Sets the slashed amount
pub fn set_slashed_amount(&mut self, amount: u64) {
self.slashed_amount = amount;
}

/// Feeds the host with the stakes.
pub fn stakes(&self) {
for (stake_data, pk) in self.stakes.values() {
Expand Down

0 comments on commit 0942b25

Please sign in to comment.