Browse Source

storage: use primary storage liason as fallback

Mokhtar Naamani 5 years ago
parent
commit
070c0c1a78
4 changed files with 20 additions and 6 deletions
  1. 1 1
      Cargo.toml
  2. 1 1
      src/lib.rs
  3. 17 3
      src/storage/data_directory.rs
  4. 1 1
      wasm/Cargo.toml

+ 1 - 1
Cargo.toml

@@ -2,7 +2,7 @@
 authors = ['Joystream']
 edition = '2018'
 name = 'joystream-node-runtime'
-version = '5.2.0'
+version = '5.3.0'
 
 [features]
 default = ['std']

+ 1 - 1
src/lib.rs

@@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
     authoring_version: 5,
-    spec_version: 2,
+    spec_version: 3,
     impl_version: 0,
     apis: RUNTIME_API_VERSIONS,
 };

+ 17 - 3
src/storage/data_directory.rs

@@ -129,6 +129,8 @@ decl_storage! {
         pub StorageProviderAddress get(storage_provider_address): Vec<u8>;
         // Default storage provider repository id
         pub StorageProviderRepoId get(storage_provider_repo_id): Vec<u8>;
+        // Default storage provider account id, overrides all active storage providers as liason if set
+        pub PrimaryLiaisonAccountId get(primary_liaison_account_id): Option<T::AccountId>;
     }
 }
 
@@ -170,9 +172,13 @@ decl_module! {
             ensure!(!<DataObjectByContentId<T>>::exists(content_id),
                 "Data object aready added under this content id");
 
-            // The liaison is something we need to take from staked roles. The idea
-            // is to select the liaison, for now randomly.
-            let liaison = T::Roles::random_account_for_role(actors::Role::Storage)?;
+            let liaison = match Self::primary_liaison_account_id() {
+                // Select primary liaison if set
+                Some(primary_liaison) => primary_liaison,
+
+                // Select liaison from staked roles if available
+                _ => T::Roles::random_account_for_role(actors::Role::Storage)?
+            };
 
             // Let's create the entry then
             let data: DataObject<T> = DataObject {
@@ -281,6 +287,14 @@ decl_module! {
             <StorageProviderAddress<T>>::put(address);
         }
 
+        fn set_primary_liaison_account_id(account: T::AccountId) {
+            <PrimaryLiaisonAccountId<T>>::put(account);
+        }
+
+        fn unset_primary_liaison_account_id() {
+            <PrimaryLiaisonAccountId<T>>::take();
+        }
+
         fn remove_known_content_id(content_id: T::ContentId) {
             let upd_content_ids: Vec<T::ContentId> = Self::known_content_ids()
                 .into_iter()

+ 1 - 1
wasm/Cargo.toml

@@ -20,4 +20,4 @@ path = '..'
 authors = ['Joystream']
 edition = '2018'
 name = 'joystream-node-runtime-wasm'
-version = '5.2.0'
+version = '5.3.0'