Browse Source

Add DefaultQuotaLimit trait type

iorveth 4 years ago
parent
commit
8ba48c2bef

+ 3 - 3
runtime-modules/storage/src/data_directory.rs

@@ -59,13 +59,13 @@ pub trait Trait:
     /// Active data object type validator.
     type IsActiveDataObjectType: data_object_type_registry::IsActiveDataObjectType<Self>;
 
-    /// Validates member id and origin combination.
+    /// Validates member id and origin combination.DefaultQuotaLimit
     type MemberOriginValidator: ActorOriginValidator<Self::Origin, MemberId<Self>, Self::AccountId>;
 
     type MaxObjectsPerInjection: Get<u32>;
 
     /// Deafult content quota limit for all actors.
-    type DefaultQuotaLimit: Get<ContentId<Self>>;
+    type DefaultQuotaLimit: Get<u32>;
 }
 
 decl_error! {
@@ -366,7 +366,7 @@ impl<T: Trait> Module<T> {
             T::DefaultQuotaLimit::get()
         };
 
-        let content_length: ContentId<T> = (content.len() as u32).into();
+        let content_length = content.len() as u32;
         ensure!(quota >= content_length, Error::<T>::QuotaLimitExceeded);
         Ok(quota - content_length)
     }

+ 2 - 0
runtime-modules/storage/src/tests/mock.rs

@@ -96,6 +96,7 @@ parameter_types! {
     pub const AvailableBlockRatio: Perbill = Perbill::one();
     pub const MinimumPeriod: u64 = 5;
     pub const MaxObjectsPerInjection: u32 = 5;
+    pub const DefaultQuotaLimit: u32 = 50;
 }
 
 impl system::Trait for Test {
@@ -179,6 +180,7 @@ impl data_directory::Trait for Test {
     type IsActiveDataObjectType = AnyDataObjectTypeIsActive;
     type MemberOriginValidator = ();
     type MaxObjectsPerInjection = MaxObjectsPerInjection;
+    type DefaultQuotaLimit = DefaultQuotaLimit;
 }
 
 impl crate::data_directory::StorageProviderHelper<Test> for () {

+ 2 - 0
runtime/src/lib.rs

@@ -478,6 +478,7 @@ impl memo::Trait for Runtime {
 
 parameter_types! {
     pub const MaxObjectsPerInjection: u32 = 100;
+    pub const DefaultQuotaLimit: u32 = 50;
 }
 
 impl storage::data_object_type_registry::Trait for Runtime {
@@ -490,6 +491,7 @@ impl storage::data_directory::Trait for Runtime {
     type IsActiveDataObjectType = DataObjectTypeRegistry;
     type MemberOriginValidator = MembershipOriginValidator<Self>;
     type MaxObjectsPerInjection = MaxObjectsPerInjection;
+    type DefaultQuotaLimit = DefaultQuotaLimit;
 }
 
 impl storage::data_object_storage_registry::Trait for Runtime {