types.rs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #[cfg(feature = "std")]
  2. use serde::{Deserialize, Serialize};
  3. use codec::{Encode, Decode};
  4. use rstd::collections::btree_set::BTreeSet;
  5. /// Terms for slashings applied to a given role
  6. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  7. #[derive(Encode, Decode, Debug, Clone, PartialEq, Eq)]
  8. pub struct SlashableTerms {
  9. /// Maximum number of slashes.
  10. pub max_count: u16,
  11. /// Maximum percentage points of remaining stake which may be slashed in a single slash.
  12. pub max_percent_pts_per_time: u16,
  13. }
  14. /// Terms for what slashing can be applied in some context
  15. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  16. #[derive(Encode, Decode, Debug, Clone, PartialEq, Eq)]
  17. pub enum SlashingTerms {
  18. Unslashable,
  19. Slashable(SlashableTerms),
  20. }
  21. /// Must be default constructible because it indirectly is a value in a storage map.
  22. /// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
  23. impl Default for SlashingTerms {
  24. fn default() -> Self {
  25. Self::Unslashable
  26. }
  27. }
  28. /// A commitment to the set of policy variables relevant to an opening.
  29. /// An applicant can observe this commitment and be secure that the terms
  30. /// of the application process cannot be changed ex-post.
  31. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  32. #[derive(Encode, Decode, Debug, Clone, Default, PartialEq, Eq)]
  33. pub struct OpeningPolicyCommitment<BlockNumber, Balance> {
  34. /// Rationing to be used
  35. pub application_rationing_policy: Option<hiring::ApplicationRationingPolicy>,
  36. /// Maximum length of review period of applications
  37. pub max_review_period_length: BlockNumber,
  38. /// Staking policy for application
  39. pub application_staking_policy: Option<hiring::StakingPolicy<Balance, BlockNumber>>,
  40. /// Staking policy for role itself
  41. pub role_staking_policy: Option<hiring::StakingPolicy<Balance, BlockNumber>>,
  42. // Slashing terms during application
  43. // pub application_slashing_terms: SlashingTerms,
  44. // Slashing terms during role, NOT application itself!
  45. pub role_slashing_terms: SlashingTerms,
  46. /// When filling an opening: Unstaking period for application stake of successful applicants
  47. pub fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
  48. /// When filling an opening:
  49. pub fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
  50. /// When filling an opening:
  51. pub fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
  52. /// When terminating a curator:
  53. pub terminate_curator_application_stake_unstaking_period: Option<BlockNumber>,
  54. /// When terminating a curator:
  55. pub terminate_curator_role_stake_unstaking_period: Option<BlockNumber>,
  56. /// When a curator exists: ..
  57. pub exit_curator_role_application_stake_unstaking_period: Option<BlockNumber>,
  58. /// When a curator exists: ..
  59. pub exit_curator_role_stake_unstaking_period: Option<BlockNumber>,
  60. }
  61. /// An opening for a curator role.
  62. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
  63. #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
  64. pub struct CuratorOpening<OpeningId, BlockNumber, Balance, CuratorApplicationId: core::cmp::Ord> {
  65. /// Identifer for underlying opening in the hiring module.
  66. pub opening_id: OpeningId,
  67. /// Set of identifiers for all curator applications ever added
  68. pub curator_applications: BTreeSet<CuratorApplicationId>,
  69. /// Commitment to policies in opening.
  70. pub policy_commitment: OpeningPolicyCommitment<BlockNumber, Balance>,
  71. }