pallet_parachain_staking/
traits.rs1use crate::weights::WeightInfo;
20use frame_support::{dispatch::PostDispatchInfo, pallet_prelude::Weight};
21use sp_runtime::DispatchErrorWithPostInfo;
22
23pub trait OnCollatorPayout<AccountId, Balance> {
24 fn on_collator_payout(
25 for_round: crate::RoundIndex,
26 collator_id: AccountId,
27 amount: Balance,
28 ) -> Weight;
29}
30impl<AccountId, Balance> OnCollatorPayout<AccountId, Balance> for () {
31 fn on_collator_payout(
32 _for_round: crate::RoundIndex,
33 _collator_id: AccountId,
34 _amount: Balance,
35 ) -> Weight {
36 Weight::zero()
37 }
38}
39
40pub trait OnNewRound {
41 fn on_new_round(round_index: crate::RoundIndex) -> Weight;
42}
43impl OnNewRound for () {
44 fn on_new_round(_round_index: crate::RoundIndex) -> Weight {
45 Weight::zero()
46 }
47}
48
49pub trait PayoutCollatorReward<Runtime: crate::Config> {
51 fn payout_collator_reward(
52 round_index: crate::RoundIndex,
53 collator_id: Runtime::AccountId,
54 amount: crate::BalanceOf<Runtime>,
55 ) -> Weight;
56}
57
58impl<Runtime: crate::Config> PayoutCollatorReward<Runtime> for () {
61 fn payout_collator_reward(
62 for_round: crate::RoundIndex,
63 collator_id: Runtime::AccountId,
64 amount: crate::BalanceOf<Runtime>,
65 ) -> Weight {
66 crate::Pallet::<Runtime>::mint_collator_reward(for_round, collator_id, amount)
67 }
68}
69
70pub trait OnInactiveCollator<Runtime: crate::Config> {
71 fn on_inactive_collator(
72 collator_id: Runtime::AccountId,
73 round: crate::RoundIndex,
74 ) -> Result<Weight, DispatchErrorWithPostInfo<PostDispatchInfo>>;
75}
76
77impl<Runtime: crate::Config> OnInactiveCollator<Runtime> for () {
78 fn on_inactive_collator(
79 collator_id: <Runtime>::AccountId,
80 _round: crate::RoundIndex,
81 ) -> Result<Weight, DispatchErrorWithPostInfo<PostDispatchInfo>> {
82 crate::Pallet::<Runtime>::go_offline_inner(collator_id)?;
83 Ok(<Runtime as crate::Config>::WeightInfo::go_offline(
84 crate::MAX_CANDIDATES,
85 ))
86 }
87}