mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 10:15:42 +00:00
Remove getters from im-online pallet (#3589)
As I've been dancing around this pallet for quite some time anyway, I decided to remove getters at once. There were only a few leftovers in tests. Related: #3326 CC @muraca
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
title: Removed `pallet::getter` usage from `pallet-im-online`
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Runtime Dev
|
||||||
|
description: |
|
||||||
|
This PR removes `pallet::getter` usage from `pallet-im-online`, and updates dependant code accordingly.
|
||||||
|
The syntax `StorageItem::<T, I>::get()` should be used instead.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: pallet-im-online
|
||||||
@@ -338,26 +338,22 @@ pub mod pallet {
|
|||||||
/// progress estimate from `NextSessionRotation`, as those estimates should be
|
/// progress estimate from `NextSessionRotation`, as those estimates should be
|
||||||
/// more accurate then the value we calculate for `HeartbeatAfter`.
|
/// more accurate then the value we calculate for `HeartbeatAfter`.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn heartbeat_after)]
|
pub type HeartbeatAfter<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
|
||||||
pub(super) type HeartbeatAfter<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
|
|
||||||
|
|
||||||
/// The current set of keys that may issue a heartbeat.
|
/// The current set of keys that may issue a heartbeat.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn keys)]
|
pub type Keys<T: Config> =
|
||||||
pub(super) type Keys<T: Config> =
|
|
||||||
StorageValue<_, WeakBoundedVec<T::AuthorityId, T::MaxKeys>, ValueQuery>;
|
StorageValue<_, WeakBoundedVec<T::AuthorityId, T::MaxKeys>, ValueQuery>;
|
||||||
|
|
||||||
/// For each session index, we keep a mapping of `SessionIndex` and `AuthIndex`.
|
/// For each session index, we keep a mapping of `SessionIndex` and `AuthIndex`.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn received_heartbeats)]
|
pub type ReceivedHeartbeats<T: Config> =
|
||||||
pub(super) type ReceivedHeartbeats<T: Config> =
|
|
||||||
StorageDoubleMap<_, Twox64Concat, SessionIndex, Twox64Concat, AuthIndex, bool>;
|
StorageDoubleMap<_, Twox64Concat, SessionIndex, Twox64Concat, AuthIndex, bool>;
|
||||||
|
|
||||||
/// For each session index, we keep a mapping of `ValidatorId<T>` to the
|
/// For each session index, we keep a mapping of `ValidatorId<T>` to the
|
||||||
/// number of blocks authored by the given authority.
|
/// number of blocks authored by the given authority.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn authored_blocks)]
|
pub type AuthoredBlocks<T: Config> = StorageDoubleMap<
|
||||||
pub(super) type AuthoredBlocks<T: Config> = StorageDoubleMap<
|
|
||||||
_,
|
_,
|
||||||
Twox64Concat,
|
Twox64Concat,
|
||||||
SessionIndex,
|
SessionIndex,
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ use sp_core::offchain::{
|
|||||||
testing::{TestOffchainExt, TestTransactionPoolExt},
|
testing::{TestOffchainExt, TestTransactionPoolExt},
|
||||||
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
|
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::testing::UintAuthorityId;
|
||||||
testing::UintAuthorityId,
|
|
||||||
transaction_validity::{InvalidTransaction, TransactionValidityError},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unresponsiveness_slash_fraction() {
|
fn test_unresponsiveness_slash_fraction() {
|
||||||
@@ -267,14 +264,14 @@ fn should_cleanup_received_heartbeats_on_session_end() {
|
|||||||
let _ = heartbeat(1, 2, 0, 1.into(), Session::validators()).unwrap();
|
let _ = heartbeat(1, 2, 0, 1.into(), Session::validators()).unwrap();
|
||||||
|
|
||||||
// the heartbeat is stored
|
// the heartbeat is stored
|
||||||
assert!(!ImOnline::received_heartbeats(&2, &0).is_none());
|
assert!(!super::pallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
|
||||||
|
|
||||||
advance_session();
|
advance_session();
|
||||||
|
|
||||||
// after the session has ended we have already processed the heartbeat
|
// after the session has ended we have already processed the heartbeat
|
||||||
// message, so any messages received on the previous session should have
|
// message, so any messages received on the previous session should have
|
||||||
// been pruned.
|
// been pruned.
|
||||||
assert!(ImOnline::received_heartbeats(&2, &0).is_none());
|
assert!(super::pallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user