Skip to content

Commit

Permalink
stake-contract: rename slashed to burnt amount
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Jun 28, 2024
1 parent 5ab1950 commit a183e02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions contracts/stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ unsafe fn hard_slash(arg_len: u32) -> u32 {
}

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

Expand Down
14 changes: 7 additions & 7 deletions contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::*;
#[derive(Debug, Default, Clone)]
pub struct StakeState {
stakes: BTreeMap<[u8; StakePublicKey::SIZE], (StakeData, StakePublicKey)>,
slashed_amount: u64,
burnt_amount: u64,
previous_block_state: BTreeMap<
[u8; StakePublicKey::SIZE],
(Option<StakeData>, StakePublicKey),
Expand All @@ -49,7 +49,7 @@ impl StakeState {
pub const fn new() -> Self {
Self {
stakes: BTreeMap::new(),
slashed_amount: 0u64,
burnt_amount: 0u64,
previous_block_state: BTreeMap::new(),
previous_block_height: 0,
}
Expand Down Expand Up @@ -279,7 +279,7 @@ impl StakeState {

/// Total amount slashed from the genesis
pub fn slashed_amount(&self) -> u64 {
self.slashed_amount
self.burnt_amount
}

/// Version of the stake contract
Expand Down Expand Up @@ -375,7 +375,7 @@ impl StakeState {
Self::deduct_module_balance(to_slash);

// Update the total slashed amount
self.slashed_amount += to_slash;
self.burnt_amount += to_slash;

rusk_abi::emit(
"hard_slash",
Expand All @@ -390,9 +390,9 @@ impl StakeState {
.or_insert((prev_value, *stake_pk));
}

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

/// Feeds the host with the stakes.
Expand Down

0 comments on commit a183e02

Please sign in to comment.