Browse Source

runtime: Rename StorageProviderAccountInfo to ServiceProviderRecord

Shamil Gadelshin 4 years ago
parent
commit
c74ec0d6f6

+ 9 - 9
runtime-modules/service-discovery/src/lib.rs

@@ -10,8 +10,8 @@
 //!
 //! ## Supported extrinsics
 //!
-//! - [set_ipns_id](./struct.Module.html#method.set_ipns_id) - Creates the StorageProviderAccountInfo to save an IPNS identity for the storage provider.
-//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the StorageProviderAccountInfo with the IPNS identity for the storage provider.
+//! - [set_ipns_id](./struct.Module.html#method.set_ipns_id) - Creates the ServiceProviderRecord to save an IPNS identity for the storage provider.
+//! - [unset_ipns_id](./struct.Module.html#method.unset_ipns_id) - Deletes the ServiceProviderRecord with the IPNS identity for the storage provider.
 //! - [set_default_lifetime](./struct.Module.html#method.set_default_lifetime) - Sets default lifetime for storage providers accounts info.
 //! - [set_bootstrap_endpoints](./struct.Module.html#method.set_bootstrap_endpoints) - Sets bootstrap endpoints for the Colossus.
 //!
@@ -63,7 +63,7 @@ pub(crate) const DEFAULT_LIFETIME: u32 = MINIMUM_LIFETIME * 24; // 24hr
 /// Defines the expiration date for the storage provider.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)]
-pub struct StorageProviderAccountInfo<BlockNumber> {
+pub struct ServiceProviderRecord<BlockNumber> {
     /// IPNS Identity.
     pub identity: IPNSIdentity,
     /// Block at which information expires.
@@ -81,11 +81,11 @@ decl_storage! {
         /// Bootstrap endpoints maintained by root
         pub BootstrapEndpoints get(fn bootstrap_endpoints): Vec<Url>;
 
-        /// Mapping of service providers' storage provider id to their StorageProviderAccountInfo
+        /// Mapping of service providers' storage provider id to their ServiceProviderRecord
         pub AccountInfoByStorageProviderId get(fn account_info_by_storage_provider_id):
-            map hasher(blake2_128_concat) StorageProviderId<T> => StorageProviderAccountInfo<T::BlockNumber>;
+            map hasher(blake2_128_concat) StorageProviderId<T> => ServiceProviderRecord<T::BlockNumber>;
 
-        /// Lifetime of an StorageProviderAccountInfo record in AccountInfoByAccountId map
+        /// Lifetime of an ServiceProviderRecord record in AccountInfoByAccountId map
         pub DefaultLifetime get(fn default_lifetime) config():
             T::BlockNumber = T::BlockNumber::from(DEFAULT_LIFETIME);
     }
@@ -115,7 +115,7 @@ decl_module! {
         /// Default deposit_event() handler
         fn deposit_event() = default;
 
-        /// Creates the StorageProviderAccountInfo to save an IPNS identity for the storage provider.
+        /// Creates the ServiceProviderRecord to save an IPNS identity for the storage provider.
         /// Requires signed storage provider credentials.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn set_ipns_id(
@@ -131,7 +131,7 @@ decl_module! {
             // == MUTATION SAFE ==
             //
 
-            <AccountInfoByStorageProviderId<T>>::insert(storage_provider_id, StorageProviderAccountInfo {
+            <AccountInfoByStorageProviderId<T>>::insert(storage_provider_id, ServiceProviderRecord {
                 identity: id.clone(),
                 expires_at: <system::Module<T>>::block_number() + Self::default_lifetime(),
             });
@@ -139,7 +139,7 @@ decl_module! {
             Self::deposit_event(RawEvent::AccountInfoUpdated(storage_provider_id, id));
         }
 
-        /// Deletes the StorageProviderAccountInfo with the IPNS identity for the storage provider.
+        /// Deletes the ServiceProviderRecord with the IPNS identity for the storage provider.
         /// Requires signed storage provider credentials.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn unset_ipns_id(origin, storage_provider_id: StorageProviderId<T>) {

+ 3 - 3
runtime-modules/service-discovery/src/tests.rs

@@ -27,7 +27,7 @@ fn set_ipns_id() {
         let account_info = Discovery::account_info_by_storage_provider_id(&storage_provider_id);
         assert_eq!(
             account_info,
-            StorageProviderAccountInfo {
+            ServiceProviderRecord {
                 identity: identity.clone(),
                 expires_at: current_block_number + ttl
             }
@@ -70,7 +70,7 @@ fn unset_ipns_id() {
 
         <AccountInfoByStorageProviderId<Test>>::insert(
             &storage_provider_id,
-            StorageProviderAccountInfo {
+            ServiceProviderRecord {
                 expires_at: 1000,
                 identity: "alice".as_bytes().to_vec(),
             },
@@ -120,7 +120,7 @@ fn is_account_info_expired() {
         let id = "alice".as_bytes().to_vec();
         <AccountInfoByStorageProviderId<Test>>::insert(
             &storage_provider_id,
-            StorageProviderAccountInfo {
+            ServiceProviderRecord {
                 expires_at,
                 identity: id.clone(),
             },

+ 1 - 1
runtime/src/tests/storage_integration.rs

@@ -28,7 +28,7 @@ fn storage_provider_helper_succeeds() {
 		let random_provider_result = <StorageProviderHelper as storage::data_directory::StorageProviderHelper<Runtime>>::get_random_storage_provider();
 		assert!(random_provider_result.is_err());
 
-		let account_info = service_discovery::StorageProviderAccountInfo{
+		let account_info = service_discovery::ServiceProviderRecord{
 			identity: Vec::new(),
 			expires_at: 1000
 		};