@@ -68,6 +68,8 @@ class BatchGetCommand extends Command {
6868 paranetNodesAccessPolicy,
6969 } = command . data ;
7070
71+ console . time ( `BatchGetCommand [PREPARE]: ${ operationId } ${ uals . length } ` ) ;
72+
7173 await this . operationIdService . updateOperationIdStatus (
7274 operationId ,
7375 blockchain ,
@@ -88,6 +90,8 @@ class BatchGetCommand extends Command {
8890
8991 const { isValid, errorMessage } = await this . validateUALs ( operationId , blockchain , uals ) ;
9092
93+ console . timeEnd ( `BatchGetCommand [PREPARE]: ${ operationId } ${ uals . length } ` ) ;
94+
9195 if ( ! isValid ) {
9296 await this . handleError (
9397 operationId ,
@@ -98,6 +102,8 @@ class BatchGetCommand extends Command {
98102 return Command . empty ( ) ;
99103 }
100104
105+ console . time ( `BatchGetCommand [NETWORK]: ${ operationId } ${ uals . length } ` ) ;
106+
101107 const currentPeerId = this . networkModuleManager . getPeerId ( ) . toB58String ( ) ;
102108 // let paranetId;
103109 const repository = TRIPLE_STORE_REPOSITORIES . DKG ;
@@ -127,6 +133,10 @@ class BatchGetCommand extends Command {
127133 OPERATION_ID_STATUS . BATCH_GET . BATCH_GET_LOCAL_START ,
128134 ) ;
129135
136+ console . timeEnd ( `BatchGetCommand [NETWORK]: ${ operationId } ${ uals . length } ` ) ;
137+
138+ console . time ( `BatchGetCommand [TOKEN_IDS]: ${ operationId } ${ uals . length } ` ) ;
139+
130140 const tokenIds = { } ;
131141
132142 const tokenIdPromises = uals . map ( async ( ual ) => {
@@ -149,19 +159,28 @@ class BatchGetCommand extends Command {
149159
150160 await Promise . all ( tokenIdPromises ) ;
151161
162+ console . timeEnd ( `BatchGetCommand [TOKEN_IDS]: ${ operationId } ${ uals . length } ` ) ;
163+
164+ console . time ( `BatchGetCommand [LOCAL_BATCH_GET]: ${ operationId } ${ uals . length } ` ) ;
165+
152166 const promises = [ ] ;
153167 const assertionPromise = this . tripleStoreService . getAssertionsInBatch (
154168 TRIPLE_STORE_REPOSITORY . DKG ,
155169 uals ,
156170 tokenIds ,
157171 TRIPLES_VISIBILITY . PUBLIC ,
172+ operationId ,
158173 ) ;
159174 promises . push ( assertionPromise ) ;
160175
161176 const [ batchAssertions ] = await Promise . all ( promises ) ;
162177
163178 const finalResult = { local : [ ] , remote : { } , metadata : { } } ;
164179
180+ console . timeEnd ( `BatchGetCommand [LOCAL_BATCH_GET]: ${ operationId } ${ uals . length } ` ) ;
181+
182+ console . time ( `BatchGetCommand [LOCAL_BATCH_GET_VALIDATE]: ${ operationId } ${ uals . length } ` ) ;
183+
165184 const localGetResultValid = await this . validateBatchResponse (
166185 batchAssertions ,
167186 blockchain ,
@@ -178,6 +197,12 @@ class BatchGetCommand extends Command {
178197 ( ual ) => ! localGetResultValid [ ual ] ,
179198 ) ;
180199
200+ console . timeEnd (
201+ `BatchGetCommand [LOCAL_BATCH_GET_VALIDATE]: ${ operationId } ${ uals . length } ` ,
202+ ) ;
203+
204+ console . time ( `BatchGetCommand [LOCAL]: ${ operationId } ${ uals . length } ` ) ;
205+
181206 ualPresentLocally . forEach ( ( ual ) => {
182207 finalResult . local . push ( ual ) ;
183208 delete tokenIds [ ual ] ;
@@ -198,6 +223,8 @@ class BatchGetCommand extends Command {
198223 return Command . empty ( ) ;
199224 }
200225
226+ console . timeEnd ( `BatchGetCommand [LOCAL]: ${ operationId } ${ uals . length } ` ) ;
227+
201228 await this . operationIdService . updateOperationIdStatus (
202229 operationId ,
203230 blockchain ,
@@ -210,6 +237,8 @@ class BatchGetCommand extends Command {
210237 OPERATION_ID_STATUS . BATCH_GET . BATCH_GET_FIND_SHARD_START ,
211238 ) ;
212239
240+ console . time ( `BatchGetCommand [FIND_SHARD]: ${ operationId } ${ uals . length } ` ) ;
241+
213242 let nodesInfo = [ ] ;
214243 // if (paranetNodesAccessPolicy === PARANET_ACCESS_POLICY.PERMISSIONED) {
215244 // const onChainNodes = await this.blockchainModuleManager.getPermissionedNodes(
@@ -247,12 +276,16 @@ class BatchGetCommand extends Command {
247276 return Command . empty ( ) ;
248277 }
249278
279+ console . timeEnd ( `BatchGetCommand [FIND_SHARD]: ${ operationId } ${ uals . length } ` ) ;
280+
250281 await this . operationIdService . updateOperationIdStatus (
251282 operationId ,
252283 blockchain ,
253284 OPERATION_ID_STATUS . BATCH_GET . BATCH_GET_FIND_SHARD_END ,
254285 ) ;
255286
287+ console . time ( `BatchGetCommand [NETWORK]: ${ operationId } ${ uals . length } ` ) ;
288+
256289 let index = 0 ;
257290 let commandCompleted = false ;
258291
@@ -280,12 +313,21 @@ class BatchGetCommand extends Command {
280313 // eslint-disable-next-line no-loop-func
281314 const messagePromises = batch . map ( async ( node ) => {
282315 try {
316+ console . time (
317+ `BatchGetCommand [NETWORK_SEND_MESSAGE]: ${ operationId } ${ uals . length } ${ node . id } ` ,
318+ ) ;
283319 const result = await this . sendMessage ( node , operationId , message ) ;
320+ console . timeEnd (
321+ `BatchGetCommand [NETWORK_SEND_MESSAGE]: ${ operationId } ${ uals . length } ${ node . id } ` ,
322+ ) ;
284323
285324 if ( commandCompleted || ! result . success ) {
286325 return ;
287326 }
288327
328+ console . time (
329+ `BatchGetCommand [NETWORK_VALIDATE_RESPONSE]: ${ operationId } ${ uals . length } ${ node . id } ` ,
330+ ) ;
289331 const validationResult = await this . validateBatchResponse (
290332 result . responseData . assertions ,
291333 blockchain ,
@@ -294,6 +336,9 @@ class BatchGetCommand extends Command {
294336 finalResult ,
295337 [ OPERATION_ID_STATUS . GET . GET_END , OPERATION_ID_STATUS . COMPLETED ] ,
296338 ) ;
339+ console . timeEnd (
340+ `BatchGetCommand [NETWORK_VALIDATE_RESPONSE]: ${ operationId } ${ uals . length } ${ node . id } ` ,
341+ ) ;
297342
298343 if ( commandCompleted ) {
299344 return ;
@@ -312,12 +357,18 @@ class BatchGetCommand extends Command {
312357
313358 if ( hasReachedThreshold ( ) && ! commandCompleted ) {
314359 commandCompleted = true ;
360+ console . time (
361+ `BatchGetCommand [NETWORK_MARK_AS_COMPLETED]: ${ operationId } ${ uals . length } ${ node . id } ` ,
362+ ) ;
315363 await this . operationService . markOperationAsCompleted (
316364 operationId ,
317365 blockchain ,
318366 finalResult ,
319367 [ OPERATION_ID_STATUS . GET . GET_END , OPERATION_ID_STATUS . COMPLETED ] ,
320368 ) ;
369+ console . timeEnd (
370+ `BatchGetCommand [NETWORK_MARK_AS_COMPLETED]: ${ operationId } ${ uals . length } ${ node . id } ` ,
371+ ) ;
321372 }
322373 } catch ( err ) {
323374 this . logger . warn ( `Node ${ node . id } failed: ${ err . message } ` ) ;
@@ -357,6 +408,8 @@ class BatchGetCommand extends Command {
357408 ) ;
358409 }
359410
411+ console . timeEnd ( `BatchGetCommand [NETWORK]: ${ operationId } ${ uals . length } ` ) ;
412+
360413 return Command . empty ( ) ;
361414 }
362415
0 commit comments