Skip to content

Commit

Permalink
Merge pull request #9 from czareko/fix/storage_access
Browse files Browse the repository at this point in the history
fix: small access optimization
  • Loading branch information
czareko authored Sep 13, 2022
2 parents ad4fa5f + 2e90e3d commit 4e029cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(PhantomData<T>);

#[pallet::hooks]
Expand Down Expand Up @@ -62,8 +61,8 @@ pub mod pallet {

//i64 is expensive as a key, we should think about something smaller
#[pallet::storage]
#[pallet::getter(fn custom_events)]
pub(super) type CustomEvents<T: Config> = StorageMap<_, Twox64Concat, i64, CustomEvent<T>,OptionQuery>;
#[pallet::getter(fn get_custom_event)]
pub(super) type CustomEvents<T: Config> = StorageMap<_,Twox64Concat, i64, CustomEvent<T>,OptionQuery>;

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
Expand Down Expand Up @@ -131,10 +130,6 @@ pub mod pallet {
pub fn get_custom_event_keys()->Option<KeyPrefixIterator<i64>>{
Some(<CustomEvents<T>>::iter_keys())
}
pub fn get_custom_event(key: i64)->Option<CustomEvent<T>>{
let ans = <CustomEvents<T>>::get(key);
Some(ans.unwrap())
}
}
}

2 changes: 1 addition & 1 deletion src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = Call;
type Index = u64;
Expand All @@ -47,6 +46,7 @@ impl system::Config for Test {
type Header = Header;
type Event = Event;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
Expand Down

0 comments on commit 4e029cb

Please sign in to comment.