From 8c6743a59ff6f879df2aa25fe3ce7eb4e2b72b2a Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Fri, 24 Nov 2023 10:04:04 +0100 Subject: [PATCH] forward 2 --- sdk/src/types/block/unlock/multi.rs | 17 +++++++++++++++-- sdk/src/types/block/unlock/signature.rs | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sdk/src/types/block/unlock/multi.rs b/sdk/src/types/block/unlock/multi.rs index b384afa77a..13d4488869 100644 --- a/sdk/src/types/block/unlock/multi.rs +++ b/sdk/src/types/block/unlock/multi.rs @@ -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; @@ -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(unlocks: &[Unlock]) -> Result<(), Error> { if VERIFY && unlocks.iter().any(Unlock::is_multi) { diff --git a/sdk/src/types/block/unlock/signature.rs b/sdk/src/types/block/unlock/signature.rs index 2df40c4781..bb9687a883 100644 --- a/sdk/src/types/block/unlock/signature.rs +++ b/sdk/src/types/block/unlock/signature.rs @@ -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) } }