Browse Source

runtime: working-group: Rename Opening and Application entities.

Shamil Gadelshin 4 years ago
parent
commit
4161cc5d9f

+ 3 - 3
runtime-modules/working-group/src/checks.rs

@@ -1,5 +1,5 @@
 use crate::{
-    ApplicationId, BalanceOf, Instance, JobOpening, MemberId, OpeningId, OpeningType, RewardPolicy,
+    ApplicationId, BalanceOf, Instance, MemberId, Opening, OpeningId, OpeningType, RewardPolicy,
     StakePolicy, Trait, Worker, WorkerId,
 };
 
@@ -35,7 +35,7 @@ pub(crate) fn ensure_origin_for_opening_type<T: Trait<I>, I: Instance>(
 // Check opening: returns the opening by id if it is exists.
 pub(crate) fn ensure_opening_exists<T: Trait<I>, I: Instance>(
     opening_id: &OpeningId,
-) -> Result<JobOpening<T::BlockNumber, BalanceOf<T>>, Error<T, I>> {
+) -> Result<Opening<T::BlockNumber, BalanceOf<T>>, Error<T, I>> {
     ensure!(
         <crate::OpeningById::<T, I>>::contains_key(opening_id),
         Error::<T, I>::OpeningDoesNotExist
@@ -232,7 +232,7 @@ pub(crate) fn ensure_valid_reward_policy<T: Trait<I>, I: Instance>(
 
 // Check application: verifies that proposed stake is enough for the opening.
 pub(crate) fn ensure_application_stake_match_opening<T: Trait<I>, I: Instance>(
-    opening: &JobOpening<T::BlockNumber, BalanceOf<T>>,
+    opening: &Opening<T::BlockNumber, BalanceOf<T>>,
     stake_parameters: &Option<StakeParameters<T::AccountId, BalanceOf<T>>>,
 ) -> DispatchResult {
     let opening_stake_balance = opening

+ 8 - 8
runtime-modules/working-group/src/lib.rs

@@ -48,8 +48,8 @@ use sp_std::vec::Vec;
 
 pub use errors::Error;
 pub use types::{
-    ApplicationId, ApplyOnOpeningParameters, BalanceOf, JobApplication, JobOpening, MemberId,
-    OpeningId, OpeningType, Penalty, RewardPolicy, StakePolicy, Worker, WorkerId,
+    Application, ApplicationId, ApplyOnOpeningParameters, BalanceOf, MemberId, Opening, OpeningId,
+    OpeningType, Penalty, RewardPolicy, StakePolicy, Worker, WorkerId,
 };
 use types::{ApplicationInfo, WorkerInfo};
 
@@ -202,14 +202,14 @@ decl_storage! {
 
         /// Maps identifier to job opening.
         pub OpeningById get(fn opening_by_id): map hasher(blake2_128_concat)
-            OpeningId => JobOpening<T::BlockNumber, BalanceOf<T>>;
+            OpeningId => Opening<T::BlockNumber, BalanceOf<T>>;
 
         /// Count of active workers.
         pub ActiveWorkerCount get(fn active_worker_count): u32;
 
         /// Maps identifier to worker application on opening.
         pub ApplicationById get(fn application_by_id) : map hasher(blake2_128_concat)
-            ApplicationId => JobApplication<T>;
+            ApplicationId => Application<T>;
 
         /// Next identifier value for new worker application.
         pub NextApplicationId get(fn next_application_id) : ApplicationId;
@@ -283,7 +283,7 @@ decl_module! {
             let hashed_description = T::Hashing::hash(&description);
 
             // Create and add worker opening.
-            let new_opening = JobOpening{
+            let new_opening = Opening{
                 opening_type,
                 created: Self::current_block(),
                 description_hash: hashed_description.as_ref().to_vec(),
@@ -342,7 +342,7 @@ decl_module! {
             let hashed_description = T::Hashing::hash(&p.description);
 
             // Make regular/lead application.
-            let application = JobApplication::<T>::new(
+            let application = Application::<T>::new(
                 &p.role_account_id,
                 &p.reward_account_id,
                 &p.stake_parameters.map(|sp| sp.staking_account_id),
@@ -847,7 +847,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Processes successful application during the fill_opening().
     fn fulfill_successful_applications(
-        opening: &JobOpening<T::BlockNumber, BalanceOf<T>>,
+        opening: &Opening<T::BlockNumber, BalanceOf<T>>,
         successful_applications_info: Vec<ApplicationInfo<T, I>>,
     ) -> BTreeMap<ApplicationId, WorkerId<T>> {
         let mut application_id_to_worker_id = BTreeMap::new();
@@ -870,7 +870,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Creates worker by the application. Deletes application from the storage.
     fn create_worker_by_application(
-        opening: &JobOpening<T::BlockNumber, BalanceOf<T>>,
+        opening: &Opening<T::BlockNumber, BalanceOf<T>>,
         application_info: &ApplicationInfo<T, I>,
     ) -> WorkerId<T> {
         // Get worker id.

+ 3 - 3
runtime-modules/working-group/src/tests/fixtures.rs

@@ -9,7 +9,7 @@ use super::hiring_workflow::HiringWorkflow;
 use super::mock::{Balances, LockId, Membership, System, Test, TestEvent, TestWorkingGroup};
 use crate::types::StakeParameters;
 use crate::{
-    ApplyOnOpeningParameters, DefaultInstance, JobApplication, JobOpening, OpeningType, Penalty,
+    Application, ApplyOnOpeningParameters, DefaultInstance, Opening, OpeningType, Penalty,
     RawEvent, RewardPolicy, StakePolicy, Worker,
 };
 
@@ -73,7 +73,7 @@ impl AddOpeningFixture {
             let actual_opening = TestWorkingGroup::opening_by_id(opening_id);
 
             let expected_hash = <Test as frame_system::Trait>::Hashing::hash(&self.description);
-            let expected_opening = JobOpening {
+            let expected_opening = Opening {
                 created: self.starting_block,
                 description_hash: expected_hash.as_ref().to_vec(),
                 opening_type: self.opening_type,
@@ -213,7 +213,7 @@ impl ApplyOnOpeningFixture {
             let actual_application = TestWorkingGroup::application_by_id(application_id);
 
             let expected_hash = <Test as frame_system::Trait>::Hashing::hash(&self.description);
-            let expected_application = JobApplication::<Test> {
+            let expected_application = Application::<Test> {
                 role_account_id: self.role_account_id,
                 reward_account_id: self.reward_account_id,
                 staking_account_id: self

+ 8 - 8
runtime-modules/working-group/src/types.rs

@@ -7,8 +7,8 @@ use sp_std::vec::Vec;
 use serde::{Deserialize, Serialize};
 use sp_std::marker::PhantomData;
 
-/// Group job application type alias.
-pub type JobApplication<T> = Application<<T as frame_system::Trait>::AccountId, MemberId<T>>;
+/// Working group job application type alias.
+pub type Application<T> = JobApplication<<T as frame_system::Trait>::AccountId, MemberId<T>>;
 
 /// Member identifier in membership::member module.
 pub type MemberId<T> = <T as membership::Trait>::MemberId;
@@ -22,10 +22,10 @@ pub type ApplicationId = u64;
 /// Type for an opening id.
 pub type OpeningId = u64;
 
-// ApplicationId - JobApplication - helper struct.
+// ApplicationId - Application - helper struct.
 pub(crate) struct ApplicationInfo<T: crate::Trait<I>, I: crate::Instance> {
     pub application_id: ApplicationId,
-    pub application: JobApplication<T>,
+    pub application: Application<T>,
     pub marker: PhantomData<I>,
 }
 
@@ -58,7 +58,7 @@ pub type BalanceOf<T> = <T as balances::Trait>::Balance;
 /// An opening represents the process of hiring one or more new actors into some available role.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, Eq)]
-pub struct JobOpening<BlockNumber: Ord, Balance> {
+pub struct Opening<BlockNumber: Ord, Balance> {
     /// Defines opening type: Leader or worker.
     pub opening_type: OpeningType,
 
@@ -97,7 +97,7 @@ impl Default for OpeningType {
 /// An application for the regular worker/lead role opening.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-pub struct Application<AccountId, MemberId> {
+pub struct JobApplication<AccountId, MemberId> {
     /// Account used to authenticate in this role.
     pub role_account_id: AccountId,
 
@@ -114,7 +114,7 @@ pub struct Application<AccountId, MemberId> {
     pub description_hash: Vec<u8>,
 }
 
-impl<AccountId: Clone, MemberId: Clone> Application<AccountId, MemberId> {
+impl<AccountId: Clone, MemberId: Clone> JobApplication<AccountId, MemberId> {
     /// Creates a new job application using parameters.
     pub fn new(
         role_account_id: &AccountId,
@@ -123,7 +123,7 @@ impl<AccountId: Clone, MemberId: Clone> Application<AccountId, MemberId> {
         member_id: &MemberId,
         description_hash: Vec<u8>,
     ) -> Self {
-        Application {
+        JobApplication {
             role_account_id: role_account_id.clone(),
             reward_account_id: reward_account_id.clone(),
             staking_account_id: staking_account_id.clone(),