Skip to content

Commit

Permalink
forward 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Nov 24, 2023
1 parent 3fa452a commit 8c6743a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions sdk/src/types/block/unlock/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ use alloc::boxed::Box;
use derive_more::Deref;
use packable::{prefix::BoxedSlicePrefix, Packable};

use crate::types::block::{address::WeightedAddressCount, protocol::WorkScore, unlock::Unlock, Error};
use crate::types::block::{
address::WeightedAddressCount,
protocol::{WorkScore, WorkScoreParameters},
unlock::Unlock,
Error,
};

pub(crate) type UnlocksCount = WeightedAddressCount;

Expand Down Expand Up @@ -38,7 +43,15 @@ impl MultiUnlock {
}
}

impl WorkScore for MultiUnlock {}
impl WorkScore for MultiUnlock {
fn work_score(&self, params: WorkScoreParameters) -> u32 {
self.0.work_score(params)
}

fn mana_cost(&self, params: crate::types::block::protocol::WorkScoreParameters, reference_mana_cost: u64) -> u64 {
reference_mana_cost * self.work_score(params) as u64
}
}

fn verify_unlocks<const VERIFY: bool>(unlocks: &[Unlock]) -> Result<(), Error> {
if VERIFY && unlocks.iter().any(Unlock::is_multi) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/unlock/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl SignatureUnlock {

impl WorkScore for SignatureUnlock {
fn work_score(&self, params: WorkScoreParameters) -> u32 {
params.signature_ed25519()
self.0.work_score(params)
}
}

Expand Down

0 comments on commit 8c6743a

Please sign in to comment.