@@ -70,17 +70,11 @@ const disputeFromGraphQL = (
7070 return obj as POIDisputeAttributes
7171}
7272
73- interface indexNode {
74- id : string
75- deployments : string [ ]
76- }
77-
7873export class Indexer {
7974 statusResolver : IndexingStatusResolver
8075 rpc : RpcClient
8176 indexerManagement : IndexerManagementClient
8277 logger : Logger
83- indexNodeIDs : string [ ]
8478 defaultAllocationAmount : BigNumber
8579 indexerAddress : string
8680 allocationManagementMode : AllocationManagementMode
@@ -90,7 +84,6 @@ export class Indexer {
9084 adminEndpoint : string ,
9185 statusResolver : IndexingStatusResolver ,
9286 indexerManagement : IndexerManagementClient ,
93- indexNodeIDs : string [ ] ,
9487 defaultAllocationAmount : BigNumber ,
9588 indexerAddress : string ,
9689 allocationManagementMode : AllocationManagementMode ,
@@ -108,7 +101,6 @@ export class Indexer {
108101 // eslint-disable-next-line @typescript-eslint/no-explicit-any
109102 this . rpc = jayson . Client . http ( adminEndpoint as any )
110103 }
111- this . indexNodeIDs = indexNodeIDs
112104 this . defaultAllocationAmount = defaultAllocationAmount
113105 }
114106
@@ -163,52 +155,6 @@ export class Indexer {
163155 }
164156 }
165157
166- async indexNodes ( ) : Promise < indexNode [ ] > {
167- try {
168- const result = await this . statusResolver . statuses
169- . query (
170- gql `
171- {
172- indexingStatuses {
173- subgraphDeployment: subgraph
174- node
175- }
176- }
177- ` ,
178- )
179- . toPromise ( )
180-
181- if ( result . error ) {
182- throw result . error
183- }
184-
185- const indexNodes : indexNode [ ] = [ ]
186- result . data . indexingStatuses . map (
187- ( status : { subgraphDeployment : string ; node : string } ) => {
188- const node = indexNodes . find ( node => node . id === status . node )
189- node
190- ? node . deployments . push ( status . subgraphDeployment )
191- : indexNodes . push ( {
192- id : status . node ,
193- deployments : [ status . subgraphDeployment ] ,
194- } )
195- } ,
196- )
197-
198- this . logger . trace ( `Queried index nodes` , {
199- indexNodes,
200- } )
201- return indexNodes
202- } catch ( error ) {
203- const err = indexerError ( IndexerErrorCode . IE018 , error )
204- this . logger . error (
205- `Failed to query index nodes API (Should get a different IE?)` ,
206- { err } ,
207- )
208- throw err
209- }
210- }
211-
212158 async indexingRules ( merged : boolean ) : Promise < IndexingRuleAttributes [ ] > {
213159 try {
214160 const result = await this . indexerManagement
@@ -760,11 +706,7 @@ export class Indexer {
760706 }
761707 }
762708
763- async deploy (
764- name : string ,
765- deployment : SubgraphDeploymentID ,
766- node_id : string ,
767- ) : Promise < void > {
709+ async deploy ( name : string , deployment : SubgraphDeploymentID ) : Promise < void > {
768710 try {
769711 this . logger . info ( `Deploy subgraph deployment` , {
770712 name,
@@ -773,7 +715,6 @@ export class Indexer {
773715 const response = await this . rpc . request ( 'subgraph_deploy' , {
774716 name,
775717 ipfs_hash : deployment . ipfsHash ,
776- node_id : node_id ,
777718 } )
778719 if ( response . error ) {
779720 throw response . error
@@ -817,61 +758,10 @@ export class Indexer {
817758 }
818759 }
819760
820- async reassign (
821- deployment : SubgraphDeploymentID ,
822- node : string ,
823- ) : Promise < void > {
824- try {
825- this . logger . info ( `Reassign subgraph deployment` , {
826- deployment : deployment . display ,
827- node,
828- } )
829- const response = await this . rpc . request ( 'subgraph_reassign' , {
830- node_id : node ,
831- ipfs_hash : deployment . ipfsHash ,
832- } )
833- if ( response . error ) {
834- throw response . error
835- }
836- } catch ( error ) {
837- if ( error . message . includes ( 'unchanged' ) ) {
838- this . logger . debug ( `Subgraph deployment assignment unchanged` , {
839- deployment : deployment . display ,
840- node,
841- } )
842- return
843- }
844- const err = indexerError ( IndexerErrorCode . IE028 , error )
845- this . logger . error ( `Failed to reassign subgraph deployment` , {
846- deployment : deployment . display ,
847- err,
848- } )
849- throw err
850- }
851- }
852-
853761 async ensure ( name : string , deployment : SubgraphDeploymentID ) : Promise < void > {
854762 try {
855- // Randomly assign to unused nodes if they exist,
856- // otherwise use the node with lowest deployments assigned
857- const indexNodes = ( await this . indexNodes ( ) ) . filter (
858- ( node : { id : string ; deployments : Array < string > } ) => {
859- return node . id && node . id !== 'removed'
860- } ,
861- )
862- const usedIndexNodeIDs = indexNodes . map ( node => node . id )
863- const unusedNodes = this . indexNodeIDs . filter (
864- nodeID => ! ( nodeID in usedIndexNodeIDs ) ,
865- )
866-
867- const targetNode = unusedNodes
868- ? unusedNodes [ Math . floor ( Math . random ( ) * unusedNodes . length ) ]
869- : indexNodes . sort ( ( nodeA , nodeB ) => {
870- return nodeA . deployments . length - nodeB . deployments . length
871- } ) [ 0 ] . id
872763 await this . create ( name )
873- await this . deploy ( name , deployment , targetNode )
874- await this . reassign ( deployment , targetNode )
764+ await this . deploy ( name , deployment )
875765 } catch ( error ) {
876766 const err = indexerError ( IndexerErrorCode . IE020 , error )
877767 this . logger . error ( `Failed to ensure subgraph deployment is indexing` , {
0 commit comments