|
@@ -327,8 +327,8 @@ decl_storage! {
|
|
|
/// Worker exit rationale text length limits.
|
|
|
pub WorkerExitRationaleText get(fn worker_exit_rationale_text) : InputValidationLengthConstraint;
|
|
|
|
|
|
- /// Worker storage text length limits.
|
|
|
- pub WorkerStorageText get(fn worker_storage_size) : InputValidationLengthConstraint;
|
|
|
+ /// Worker storage size upper bound.
|
|
|
+ pub WorkerStorageSize get(fn worker_storage_size) : u16;
|
|
|
|
|
|
/// Map member id by hiring application id.
|
|
|
/// Required by StakingEventsHandler callback call to refund the balance on unstaking.
|
|
@@ -341,7 +341,7 @@ decl_storage! {
|
|
|
config(opening_human_readable_text_constraint): InputValidationLengthConstraint;
|
|
|
config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint;
|
|
|
config(worker_exit_rationale_text_constraint): InputValidationLengthConstraint;
|
|
|
- config(worker_storage_size_constraint): InputValidationLengthConstraint;
|
|
|
+ config(worker_storage_size_constraint): u16;
|
|
|
build(|config: &GenesisConfig<T, I>| {
|
|
|
Module::<T, I>::initialize_working_group(
|
|
|
config.opening_human_readable_text_constraint,
|
|
@@ -1367,13 +1367,11 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
}
|
|
|
|
|
|
fn ensure_worker_role_storage_text_is_valid(text: &[u8]) -> DispatchResult {
|
|
|
- Self::worker_storage_size()
|
|
|
- .ensure_valid(
|
|
|
- text.len(),
|
|
|
- Error::<T, I>::WorkerStorageTextTooShort.into(),
|
|
|
- Error::<T, I>::WorkerStorageTextTooLong.into(),
|
|
|
- )
|
|
|
- .map_err(|e| DispatchError::Other(e))
|
|
|
+ ensure!(
|
|
|
+ text.len() as u16 <= Self::worker_storage_size(),
|
|
|
+ Error::<T, I>::WorkerStorageValueTooLong
|
|
|
+ );
|
|
|
+ Ok(())
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1383,8 +1381,8 @@ pub fn default_text_constraint() -> InputValidationLengthConstraint {
|
|
|
}
|
|
|
|
|
|
/// Creates default storage size constraint.
|
|
|
-pub fn default_storage_size_constraint() -> InputValidationLengthConstraint {
|
|
|
- InputValidationLengthConstraint::new(0, 2048)
|
|
|
+pub fn default_storage_size_constraint() -> u16 {
|
|
|
+ 2048
|
|
|
}
|
|
|
|
|
|
impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
@@ -1539,7 +1537,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
opening_human_readable_text_constraint: InputValidationLengthConstraint,
|
|
|
worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
|
|
|
worker_exit_rationale_text_constraint: InputValidationLengthConstraint,
|
|
|
- worker_storage_size_constraint: InputValidationLengthConstraint,
|
|
|
+ worker_storage_size_constraint: u16,
|
|
|
working_group_mint_capacity: minting::BalanceOf<T>,
|
|
|
) {
|
|
|
// Create a mint.
|
|
@@ -1557,7 +1555,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
|
|
worker_application_human_readable_text_constraint,
|
|
|
);
|
|
|
<WorkerExitRationaleText<I>>::put(worker_exit_rationale_text_constraint);
|
|
|
- <WorkerStorageText<I>>::put(worker_storage_size_constraint);
|
|
|
+ <WorkerStorageSize<I>>::put(worker_storage_size_constraint);
|
|
|
}
|
|
|
|
|
|
// Set worker id as a leader id.
|