Skip to content

Commit b557493

Browse files
committed
emit updating myc-twin map event
1 parent 135adcf commit b557493

File tree

3 files changed

+4
-65
lines changed

3 files changed

+4
-65
lines changed

substrate-node/pallets/pallet-tfgrid/src/benchmarking.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -748,25 +748,6 @@ benchmarks! {
748748
assert_eq!(TfgridModule::<T>::twin_by_mycelium_pk(&mycelium_pk), Some(twin_id));
749749
}
750750

751-
// get_twin_by_mycelium_pk
752-
// get_twin_by_mycelium_pk {
753-
// let caller: T::AccountId = whitelisted_caller();
754-
// _create_twin::<T>(caller.clone());
755-
// let twin_id = 1;
756-
// let mycelium_pk = get_mycelium_pk_input(b"some_mycelium_pk");
757-
758-
// // First set the mycelium pk
759-
// assert_ok!(TfgridModule::<T>::set_twin_mycelium_pk(
760-
// RawOrigin::Signed(caller.clone()).into(),
761-
// twin_id,
762-
// mycelium_pk.clone()
763-
// ));
764-
// }: _(RawOrigin::Signed(caller), mycelium_pk.clone())
765-
// verify {
766-
// let twin = TfgridModule::<T>::twins(twin_id).unwrap();
767-
// assert_last_event::<T>(Event::TwinStored(twin).into());
768-
// }
769-
770751
// Calling the `impl_benchmark_test_suite` macro inside the `benchmarks`
771752
// block will generate one #[test] function per benchmark
772753
impl_benchmark_test_suite!(TfgridModule, crate::mock::new_test_ext(), crate::mock::TestRuntime)

substrate-node/pallets/pallet-tfgrid/src/lib.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ pub mod pallet {
423423
TwinEntityRemoved(u32, u32),
424424
TwinDeleted(u32),
425425
TwinAccountBounded(u32, T::AccountId),
426+
TwinMyceliumPkSet(u32, MyceliumPkInput),
426427

427428
PricingPolicyStored(types::PricingPolicy<T::AccountId>),
428429
// CertificationCodeStored(types::CertificationCodes),
@@ -1267,28 +1268,10 @@ pub mod pallet {
12671268
// Store the mapping
12681269
TwinByMyceliumPk::<T>::insert(&mycelium_pk, twin_id);
12691270

1271+
// Emit event that mycelium-twin mapping is updated
1272+
Self::deposit_event(Event::TwinMyceliumPkSet(twin_id, mycelium_pk));
1273+
12701274
Ok(().into())
12711275
}
1272-
1273-
// #[pallet::call_index(41)]
1274-
// #[pallet::weight(<T as Config>::WeightInfo::get_twin_by_mycelium_pk())]
1275-
// pub fn get_twin_by_mycelium_pk(
1276-
// origin: OriginFor<T>,
1277-
// mycelium_pk: MyceliumPkInput,
1278-
// ) -> DispatchResultWithPostInfo {
1279-
// let _account_id = ensure_signed(origin)?;
1280-
1281-
// // Get twin ID from mycelium pk
1282-
// let twin_id = TwinByMyceliumPk::<T>::get(&mycelium_pk).ok_or(Error::<T>::TwinNotExists)?;
1283-
1284-
// // Get the full twin object
1285-
// let twin = Twins::<T>::get(twin_id).ok_or(Error::<T>::TwinNotExists)?;
1286-
1287-
// // For now, we'll just return success. In a real implementation, you might want to
1288-
// // emit an event or return the twin data in some way
1289-
// Self::deposit_event(Event::TwinStored(twin));
1290-
1291-
// Ok(().into())
1292-
// }
12931276
}
12941277
}

substrate-node/pallets/pallet-tfgrid/src/weights.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pub trait WeightInfo {
6666
fn bond_twin_account() -> Weight;
6767
fn report_uptime_v2() -> Weight;
6868
fn set_twin_mycelium_pk() -> Weight;
69-
// fn get_twin_by_mycelium_pk() -> Weight;
7069
}
7170

7271
/// Weights for pallet_tfgrid using the Substrate node and recommended hardware.
@@ -563,18 +562,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
563562
.saturating_add(T::DbWeight::get().reads(1_u64))
564563
.saturating_add(T::DbWeight::get().writes(1_u64))
565564
}
566-
// / Storage: `TfgridModule::TwinByMyceliumPk` (r:1 w:0)
567-
// / Proof: `TfgridModule::TwinByMyceliumPk` (`max_values`: None, `max_size`: None, mode: `Measured`)
568-
// / Storage: `TfgridModule::Twins` (r:1 w:0)
569-
// / Proof: `TfgridModule::Twins` (`max_values`: None, `max_size`: None, mode: `Measured`)
570-
// fn get_twin_by_mycelium_pk() -> Weight {
571-
// // Proof Size summary in bytes:
572-
// // Measured: `387`
573-
// // Estimated: `3852`
574-
// // Minimum execution time: 11_743_000 picoseconds.
575-
// Weight::from_parts(12_053_000, 3852)
576-
// .saturating_add(T::DbWeight::get().reads(2_u64))
577-
// }
578565
}
579566

580567
// For backwards compatibility and tests
@@ -1070,16 +1057,4 @@ impl WeightInfo for () {
10701057
.saturating_add(RocksDbWeight::get().reads(1_u64))
10711058
.saturating_add(RocksDbWeight::get().writes(1_u64))
10721059
}
1073-
// / Storage: `TfgridModule::TwinByMyceliumPk` (r:1 w:0)
1074-
// / Proof: `TfgridModule::TwinByMyceliumPk` (`max_values`: None, `max_size`: None, mode: `Measured`)
1075-
// / Storage: `TfgridModule::Twins` (r:1 w:0)
1076-
// / Proof: `TfgridModule::Twins` (`max_values`: None, `max_size`: None, mode: `Measured`)
1077-
// fn get_twin_by_mycelium_pk() -> Weight {
1078-
// // Proof Size summary in bytes:
1079-
// // Measured: `387`
1080-
// // Estimated: `3852`
1081-
// // Minimum execution time: 11_743_000 picoseconds.
1082-
// Weight::from_parts(12_053_000, 3852)
1083-
// .saturating_add(RocksDbWeight::get().reads(2_u64))
1084-
// }
10851060
}

0 commit comments

Comments
 (0)