Skip to content

Commit dbc18da

Browse files
authored
entry: Add Hash to Identifier Lookup (#618)
Signed-off-by: Shreevatsa N <vatsa@dhiway.com>
1 parent aad0b28 commit dbc18da

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pallets/entry/src/lib.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,28 @@ pub mod pallet {
127127
/// It maps Registry Entry Identifier to Registry Entry Details.
128128
#[pallet::storage]
129129
pub type RegistryEntries<T: Config> =
130-
StorageMap<_, Blake2_128Concat, RegistryEntryIdOf, RegistryEntryDetailsOf<T>, OptionQuery>;
130+
StorageMap<
131+
_,
132+
Blake2_128Concat,
133+
RegistryEntryIdOf,
134+
RegistryEntryDetailsOf<T>,
135+
OptionQuery
136+
>;
137+
138+
/// Storage to map for Entry hashes to corresponding Registry Identifiers.
139+
/// It being a storage double-map will have the Registry Entry Hash and the Registry ID
140+
/// as the key, whereas the value resulted is the Registry Entry Identifier.
141+
#[pallet::storage]
142+
pub type HashToIdentifier<T> =
143+
StorageDoubleMap<
144+
_,
145+
Blake2_128Concat,
146+
RegistryEntryHashOf<T>,
147+
Blake2_128Concat,
148+
RegistryIdentifierOf,
149+
RegistryEntryIdOf,
150+
OptionQuery
151+
>;
131152

132153
#[pallet::error]
133154
pub enum Error<T> {
@@ -271,6 +292,8 @@ pub mod pallet {
271292

272293
RegistryEntries::<T>::insert(&registry_entry_id, registry_entry);
273294

295+
HashToIdentifier::<T>::insert(&tx_hash, &registry_id, &registry_entry_id);
296+
274297
Self::record_activity(&registry_entry_id, b"RegistryEntryCreated")?;
275298

276299
Self::deposit_event(Event::RegistryEntryCreated {
@@ -343,6 +366,8 @@ pub mod pallet {
343366

344367
RegistryEntries::<T>::insert(&registry_entry_id, entry);
345368

369+
HashToIdentifier::<T>::insert(&tx_hash, &registry_id, &registry_entry_id);
370+
346371
Self::record_activity(&registry_entry_id, b"RegistryEntryUpdated")?;
347372

348373
Self::deposit_event(Event::RegistryEntryUpdated {

0 commit comments

Comments
 (0)