Ver código fonte

Adjustments related to https://github.com/Joystream/joystream/pull/2847

Leszek Wiesner 3 anos atrás
pai
commit
2e71cde144

+ 9 - 12
distributor-node/src/services/networking/NetworkingService.ts

@@ -94,13 +94,13 @@ export class NetworkingService {
   }
 
   private prepareStorageNodeEndpoints(details: DataObjectDetailsFragment) {
-    const endpointsData = details.storageBag.storageAssignments
-      .filter((a) => a.storageBucket.operatorStatus.__typename === 'StorageBucketOperatorStatusActive')
-      .map((a) => {
-        const rootEndpoint = a.storageBucket.operatorMetadata?.nodeEndpoint
+    const endpointsData = details.storageBag.storageBuckets
+      .filter((bucket) => bucket.operatorStatus.__typename === 'StorageBucketOperatorStatusActive')
+      .map((bucket) => {
+        const rootEndpoint = bucket.operatorMetadata?.nodeEndpoint
         const apiEndpoint = rootEndpoint ? this.getApiEndpoint(rootEndpoint) : ''
         return {
-          bucketId: a.storageBucket.id,
+          bucketId: bucket.id,
           endpoint: apiEndpoint,
         }
       })
@@ -116,8 +116,7 @@ export class NetworkingService {
 
   private getDataObjectActiveDistributorsSet(objectDetails: DataObjectDetailsFragment): Set<number> {
     const activeDistributorsSet = new Set<number>()
-    const { distirbutionAssignments } = objectDetails.storageBag
-    const distributionBuckets = distirbutionAssignments.map((a) => a.distributionBucket)
+    const { distributionBuckets } = objectDetails.storageBag
     for (const bucket of distributionBuckets) {
       for (const operator of bucket.operators) {
         if (operator.status === DistributionBucketOperatorStatus.Active) {
@@ -140,9 +139,7 @@ export class NetworkingService {
         isSupported = typeof this.config.workerId === 'number' ? distributors.has(this.config.workerId) : false
       } else {
         const supportedBucketIds = this.config.buckets.map((id) => id.toString())
-        isSupported = details.storageBag.distirbutionAssignments.some((a) =>
-          supportedBucketIds.includes(a.distributionBucket.id)
-        )
+        isSupported = details.storageBag.distributionBuckets.some((b) => supportedBucketIds.includes(b.id))
       }
       data = {
         objectId,
@@ -365,8 +362,8 @@ export class NetworkingService {
       : []
     const objectsData = new Map<string, DataObjectData>()
     data.forEach((bucket) => {
-      bucket.bagAssignments.forEach((a) => {
-        a.storageBag.objects.forEach((object) => {
+      bucket.bags.forEach((bag) => {
+        bag.objects.forEach((object) => {
           const { ipfsHash, id, size } = object
           objectsData.set(id, { contentHash: ipfsHash, objectId: id, size: parseInt(size) })
         })

+ 140 - 102
distributor-node/src/services/networking/query-node/generated/queries.ts

@@ -1,100 +1,130 @@
-import * as Types from './schema';
+import * as Types from './schema'
 
-import gql from 'graphql-tag';
-export type DistributionBucketOperatorDetailsFragment = { workerId: number, status: Types.DistributionBucketOperatorStatus };
+import gql from 'graphql-tag'
+export type DistributionBucketOperatorDetailsFragment = {
+  workerId: number
+  status: Types.DistributionBucketOperatorStatus
+}
 
-export type DistributionBucketDetailsFragment = { id: string, operators: Array<DistributionBucketOperatorDetailsFragment> };
+export type DistributionBucketDetailsFragment = {
+  id: string
+  operators: Array<DistributionBucketOperatorDetailsFragment>
+}
 
-export type StorageBucketDetailsFragment = { id: string, operatorMetadata?: Types.Maybe<{ nodeEndpoint?: Types.Maybe<string> }>, operatorStatus: { __typename: 'StorageBucketOperatorStatusMissing' } | { __typename: 'StorageBucketOperatorStatusInvited' } | { __typename: 'StorageBucketOperatorStatusActive' } };
+export type StorageBucketDetailsFragment = {
+  id: string
+  operatorMetadata?: Types.Maybe<{ nodeEndpoint?: Types.Maybe<string> }>
+  operatorStatus:
+    | { __typename: 'StorageBucketOperatorStatusMissing' }
+    | { __typename: 'StorageBucketOperatorStatusInvited' }
+    | { __typename: 'StorageBucketOperatorStatusActive' }
+}
 
-export type DataObjectDetailsFragment = { id: string, size: any, ipfsHash: string, isAccepted: boolean, storageBag: { storageAssignments: Array<{ storageBucket: StorageBucketDetailsFragment }>, distirbutionAssignments: Array<{ distributionBucket: DistributionBucketDetailsFragment }> } };
+export type DataObjectDetailsFragment = {
+  id: string
+  size: any
+  ipfsHash: string
+  isAccepted: boolean
+  storageBag: {
+    storageBuckets: Array<StorageBucketDetailsFragment>
+    distributionBuckets: Array<DistributionBucketDetailsFragment>
+  }
+}
 
 export type GetDataObjectDetailsQueryVariables = Types.Exact<{
-  id: Types.Scalars['ID'];
-}>;
-
+  id: Types.Scalars['ID']
+}>
 
-export type GetDataObjectDetailsQuery = { storageDataObjectByUniqueInput?: Types.Maybe<DataObjectDetailsFragment> };
+export type GetDataObjectDetailsQuery = { storageDataObjectByUniqueInput?: Types.Maybe<DataObjectDetailsFragment> }
 
-export type DistirubtionBucketWithObjectsFragment = { id: string, bagAssignments: Array<{ storageBag: { objects: Array<{ id: string, size: any, ipfsHash: string }> } }> };
+export type DistirubtionBucketWithObjectsFragment = {
+  id: string
+  bags: Array<{ objects: Array<{ id: string; size: any; ipfsHash: string }> }>
+}
 
 export type GetDistributionBucketsWithObjectsByIdsQueryVariables = Types.Exact<{
-  ids?: Types.Maybe<Array<Types.Scalars['ID']> | Types.Scalars['ID']>;
-}>;
-
+  ids?: Types.Maybe<Array<Types.Scalars['ID']> | Types.Scalars['ID']>
+}>
 
-export type GetDistributionBucketsWithObjectsByIdsQuery = { distributionBuckets: Array<DistirubtionBucketWithObjectsFragment> };
+export type GetDistributionBucketsWithObjectsByIdsQuery = {
+  distributionBuckets: Array<DistirubtionBucketWithObjectsFragment>
+}
 
 export type GetDistributionBucketsWithObjectsByWorkerIdQueryVariables = Types.Exact<{
-  workerId: Types.Scalars['Int'];
-}>;
+  workerId: Types.Scalars['Int']
+}>
 
+export type GetDistributionBucketsWithObjectsByWorkerIdQuery = {
+  distributionBuckets: Array<DistirubtionBucketWithObjectsFragment>
+}
 
-export type GetDistributionBucketsWithObjectsByWorkerIdQuery = { distributionBuckets: Array<DistirubtionBucketWithObjectsFragment> };
-
-export type StorageBucketOperatorFieldsFragment = { id: string, operatorMetadata?: Types.Maybe<{ nodeEndpoint?: Types.Maybe<string> }> };
+export type StorageBucketOperatorFieldsFragment = {
+  id: string
+  operatorMetadata?: Types.Maybe<{ nodeEndpoint?: Types.Maybe<string> }>
+}
 
-export type StorageBucketsConnectionFieldsFragment = { edges: Array<{ node: StorageBucketOperatorFieldsFragment }>, pageInfo: { hasNextPage: boolean, endCursor?: Types.Maybe<string> } };
+export type StorageBucketsConnectionFieldsFragment = {
+  edges: Array<{ node: StorageBucketOperatorFieldsFragment }>
+  pageInfo: { hasNextPage: boolean; endCursor?: Types.Maybe<string> }
+}
 
 export type GetActiveStorageBucketOperatorsDataQueryVariables = Types.Exact<{
-  limit: Types.Scalars['Int'];
-  lastCursor?: Types.Maybe<Types.Scalars['String']>;
-}>;
-
+  limit: Types.Scalars['Int']
+  lastCursor?: Types.Maybe<Types.Scalars['String']>
+}>
 
-export type GetActiveStorageBucketOperatorsDataQuery = { storageBucketsConnection: StorageBucketsConnectionFieldsFragment };
+export type GetActiveStorageBucketOperatorsDataQuery = {
+  storageBucketsConnection: StorageBucketsConnectionFieldsFragment
+}
 
 export const StorageBucketDetails = gql`
-    fragment StorageBucketDetails on StorageBucket {
-  id
-  operatorMetadata {
-    nodeEndpoint
-  }
-  operatorStatus {
-    __typename
+  fragment StorageBucketDetails on StorageBucket {
+    id
+    operatorMetadata {
+      nodeEndpoint
+    }
+    operatorStatus {
+      __typename
+    }
   }
-}
-    `;
+`
 export const DistributionBucketOperatorDetails = gql`
-    fragment DistributionBucketOperatorDetails on DistributionBucketOperator {
-  workerId
-  status
-}
-    `;
+  fragment DistributionBucketOperatorDetails on DistributionBucketOperator {
+    workerId
+    status
+  }
+`
 export const DistributionBucketDetails = gql`
-    fragment DistributionBucketDetails on DistributionBucket {
-  id
-  operators {
-    ...DistributionBucketOperatorDetails
+  fragment DistributionBucketDetails on DistributionBucket {
+    id
+    operators {
+      ...DistributionBucketOperatorDetails
+    }
   }
-}
-    ${DistributionBucketOperatorDetails}`;
+  ${DistributionBucketOperatorDetails}
+`
 export const DataObjectDetails = gql`
-    fragment DataObjectDetails on StorageDataObject {
-  id
-  size
-  ipfsHash
-  isAccepted
-  storageBag {
-    storageAssignments {
-      storageBucket {
+  fragment DataObjectDetails on StorageDataObject {
+    id
+    size
+    ipfsHash
+    isAccepted
+    storageBag {
+      storageBuckets {
         ...StorageBucketDetails
       }
-    }
-    distirbutionAssignments {
-      distributionBucket {
+      distributionBuckets {
         ...DistributionBucketDetails
       }
     }
   }
-}
-    ${StorageBucketDetails}
-${DistributionBucketDetails}`;
+  ${StorageBucketDetails}
+  ${DistributionBucketDetails}
+`
 export const DistirubtionBucketWithObjects = gql`
-    fragment DistirubtionBucketWithObjects on DistributionBucket {
-  id
-  bagAssignments {
-    storageBag {
+  fragment DistirubtionBucketWithObjects on DistributionBucket {
+    id
+    bags {
       objects {
         id
         size
@@ -102,54 +132,62 @@ export const DistirubtionBucketWithObjects = gql`
       }
     }
   }
-}
-    `;
+`
 export const StorageBucketOperatorFields = gql`
-    fragment StorageBucketOperatorFields on StorageBucket {
-  id
-  operatorMetadata {
-    nodeEndpoint
+  fragment StorageBucketOperatorFields on StorageBucket {
+    id
+    operatorMetadata {
+      nodeEndpoint
+    }
   }
-}
-    `;
+`
 export const StorageBucketsConnectionFields = gql`
-    fragment StorageBucketsConnectionFields on StorageBucketConnection {
-  edges {
-    node {
-      ...StorageBucketOperatorFields
+  fragment StorageBucketsConnectionFields on StorageBucketConnection {
+    edges {
+      node {
+        ...StorageBucketOperatorFields
+      }
+    }
+    pageInfo {
+      hasNextPage
+      endCursor
     }
   }
-  pageInfo {
-    hasNextPage
-    endCursor
-  }
-}
-    ${StorageBucketOperatorFields}`;
+  ${StorageBucketOperatorFields}
+`
 export const GetDataObjectDetails = gql`
-    query getDataObjectDetails($id: ID!) {
-  storageDataObjectByUniqueInput(where: {id: $id}) {
-    ...DataObjectDetails
+  query getDataObjectDetails($id: ID!) {
+    storageDataObjectByUniqueInput(where: { id: $id }) {
+      ...DataObjectDetails
+    }
   }
-}
-    ${DataObjectDetails}`;
+  ${DataObjectDetails}
+`
 export const GetDistributionBucketsWithObjectsByIds = gql`
-    query getDistributionBucketsWithObjectsByIds($ids: [ID!]) {
-  distributionBuckets(where: {id_in: $ids}) {
-    ...DistirubtionBucketWithObjects
+  query getDistributionBucketsWithObjectsByIds($ids: [ID!]) {
+    distributionBuckets(where: { id_in: $ids }) {
+      ...DistirubtionBucketWithObjects
+    }
   }
-}
-    ${DistirubtionBucketWithObjects}`;
+  ${DistirubtionBucketWithObjects}
+`
 export const GetDistributionBucketsWithObjectsByWorkerId = gql`
-    query getDistributionBucketsWithObjectsByWorkerId($workerId: Int!) {
-  distributionBuckets(where: {operators_some: {workerId_eq: $workerId, status_eq: ACTIVE}}) {
-    ...DistirubtionBucketWithObjects
+  query getDistributionBucketsWithObjectsByWorkerId($workerId: Int!) {
+    distributionBuckets(where: { operators_some: { workerId_eq: $workerId, status_eq: ACTIVE } }) {
+      ...DistirubtionBucketWithObjects
+    }
   }
-}
-    ${DistirubtionBucketWithObjects}`;
+  ${DistirubtionBucketWithObjects}
+`
 export const GetActiveStorageBucketOperatorsData = gql`
-    query getActiveStorageBucketOperatorsData($limit: Int!, $lastCursor: String) {
-  storageBucketsConnection(first: $limit, after: $lastCursor, where: {operatorStatus_json: {isTypeOf_eq: "StorageBucketOperatorStatusActive"}}) {
-    ...StorageBucketsConnectionFields
+  query getActiveStorageBucketOperatorsData($limit: Int!, $lastCursor: String) {
+    storageBucketsConnection(
+      first: $limit
+      after: $lastCursor
+      where: { operatorStatus_json: { isTypeOf_eq: "StorageBucketOperatorStatusActive" } }
+    ) {
+      ...StorageBucketsConnectionFields
+    }
   }
-}
-    ${StorageBucketsConnectionFields}`;
+  ${StorageBucketsConnectionFields}
+`

Diferenças do arquivo suprimidas por serem muito extensas
+ 41 - 841
distributor-node/src/services/networking/query-node/generated/schema.ts


+ 9 - 15
distributor-node/src/services/networking/query-node/queries/queries.graphql

@@ -26,15 +26,11 @@ fragment DataObjectDetails on StorageDataObject {
   ipfsHash
   isAccepted
   storageBag {
-    storageAssignments {
-      storageBucket {
-        ...StorageBucketDetails
-      }
+    storageBuckets {
+      ...StorageBucketDetails
     }
-    distirbutionAssignments {
-      distributionBucket {
-        ...DistributionBucketDetails
-      }
+    distributionBuckets {
+      ...DistributionBucketDetails
     }
   }
 }
@@ -47,13 +43,11 @@ query getDataObjectDetails($id: ID!) {
 
 fragment DistirubtionBucketWithObjects on DistributionBucket {
   id
-  bagAssignments {
-    storageBag {
-      objects {
-        id
-        size
-        ipfsHash
-      }
+  bags {
+    objects {
+      id
+      size
+      ipfsHash
     }
   }
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff