Skip to content

Commit 25ca564

Browse files
committed
More progress
1 parent d085af5 commit 25ca564

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

pallets/did/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub mod pallet {
173173
DidEncryptionKey, DidSignature, DidVerifiableIdentifier, DidVerificationKey, RelationshipDeriveError,
174174
},
175175
service_endpoints::{utils as service_endpoints_utils, ServiceEndpointId},
176-
traits::DeletionHelper,
176+
traits::{DeletionHelper, SteppedDeletion},
177177
};
178178

179179
/// The current storage version.
@@ -1285,6 +1285,7 @@ pub mod pallet {
12851285
} else {
12861286
return Err(DispatchError::BadOrigin);
12871287
};
1288+
12881289
Ok(())
12891290
}
12901291
}

pallets/did/src/traits.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,57 @@
1616

1717
// If you feel like getting in touch with us, you can do so at [email protected]
1818

19+
use sp_weights::Weight;
20+
1921
use crate::{Config, DidIdentifierOf};
2022

2123
/// Runtime-injected logic to support the DID pallet in making sure no dangling
2224
/// references is left before deleting a given DID.
2325
pub trait DeletionHelper<T>
2426
where
2527
T: Config,
28+
<Self::DeletionIter as Iterator>::Item: SteppedDeletion,
2629
{
27-
/// Return the count of resources linked to a given DID.
28-
fn linked_resources_count(did: &DidIdentifierOf<T>) -> u32;
30+
type DeletionIter: Iterator;
31+
32+
fn deletion_iter(did: &DidIdentifierOf<T>) -> Self::DeletionIter;
2933
}
3034

3135
impl<T> DeletionHelper<T> for ()
3236
where
3337
T: Config,
3438
{
35-
fn linked_resources_count(_did: &DidIdentifierOf<T>) -> u32 {
36-
0
39+
type DeletionIter = EmptyIterator;
40+
41+
fn deletion_iter(_did: &DidIdentifierOf<T>) -> Self::DeletionIter {
42+
EmptyIterator
3743
}
3844
}
45+
46+
pub struct EmptyIterator;
47+
48+
impl Iterator for EmptyIterator {
49+
type Item = ();
50+
51+
fn next(&mut self) -> Option<Self::Item> {
52+
Some(())
53+
}
54+
}
55+
56+
pub trait SteppedDeletion {
57+
type VerifiedInfo;
58+
59+
fn pre_check(remaining_weight: Weight) -> Option<Self::VerifiedInfo>;
60+
61+
fn execute(info: Self::VerifiedInfo);
62+
}
63+
64+
impl SteppedDeletion for () {
65+
type VerifiedInfo = ();
66+
67+
fn pre_check(_remaining_weight: Weight) -> Self::VerifiedInfo {
68+
()
69+
}
70+
71+
fn execute(info: Self::VerifiedInfo) {}
72+
}

0 commit comments

Comments
 (0)