From 9cf293fa0c5b2ee525555d8b007f8aa3e86369a8 Mon Sep 17 00:00:00 2001 From: shunmugam Date: Tue, 10 Sep 2019 15:38:28 +0530 Subject: [PATCH 1/4] commit_id search --- server/controllers/BlockchainBlock.ts | 75 +++++++++++++++---- .../block-detail/block-detail.component.html | 56 +++++++++++++- 2 files changed, 115 insertions(+), 16 deletions(-) diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index abc5e94..1b7f4ec 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -711,24 +711,66 @@ export class BlockchainBlockController { next: NextFunction, ) => { try { - var BlockchainBlockFetchQuery = await getConnection(Global.network).getRepository( - BlockchainBlock, + var BlockchainOutputFetchQuery = await getConnection(Global.network).getRepository( + BlockchainOutput, ).findOne({ select: [ - 'Hash', - 'Height', - 'Timestamp', - 'TotalDifficultyCuckaroo', - 'TotalDifficultyCuckatoo', - 'TotalDifficultyProgpow', - 'TotalDifficultyRandomx', - 'PreviousId', - 'EdgeBits', - 'SecondaryScaling', - 'Proof', + 'BlockId' ], - where: { Hash: request.params.hash }, + where: { Commit : request.params.hash }, }); + + if(BlockchainOutputFetchQuery){ + var BlockchainBlockFetchQuery = await getConnection(Global.network).getRepository( + BlockchainBlock, + ).findOne({ + select: [ + 'Hash', + 'Height', + 'Timestamp', + 'TotalDifficultyCuckaroo', + 'TotalDifficultyCuckatoo', + 'TotalDifficultyProgpow', + 'TotalDifficultyRandomx', + 'PreviousId', + 'EdgeBits', + 'SecondaryScaling', + 'Proof', + ], + where: { Hash: BlockchainOutputFetchQuery.BlockId }, + }); + }else{ + var BlockchainBlockFetchQuery = await getConnection(Global.network).getRepository( + BlockchainBlock, + ).findOne({ + select: [ + 'Hash', + 'Height', + 'Timestamp', + 'TotalDifficultyCuckaroo', + 'TotalDifficultyCuckatoo', + 'TotalDifficultyProgpow', + 'TotalDifficultyRandomx', + 'PreviousId', + 'EdgeBits', + 'SecondaryScaling', + 'Proof', + ], + where: { Hash: request.params.hash }, + }); + } + + + + + + + + + + + + let paramVal = request.params.hash; if ( !BlockchainBlockFetchQuery && @@ -768,7 +810,7 @@ export class BlockchainBlockController { const BlockchainBlockOutputFetchQuery = await getConnection(Global.network).getRepository( BlockchainOutput, ).find({ - select: ['OutputType', 'Commit', 'Spent'], + select: ['OutputType', 'Commit', 'Spent', 'MerkleProof', 'MmrIndex', 'ProofHash', 'Proof'], where: { BlockId: BlockchainBlockFetchQuery.Hash }, }); @@ -892,6 +934,8 @@ export class BlockchainBlockController { let arr = balance.match(/.{1,6}/g); BlockchainBlockFetchQuery['hasharray'] = arr.map(i => '#' + i); + var viewType = BlockchainOutputFetchQuery ? 'Commit' : 'HashHeight'; + BlockchainBlockFetchQuery ? response.status(200).json({ status: 200, @@ -902,6 +946,7 @@ export class BlockchainBlockController { BlockchainBlockInputFetchQuery: BlockchainBlockInputFetchQuery, BlockchainBlockOutputFetchQuery: BlockchainBlockOutputFetchQuery, BlockchainBlockKernalFetchQuery: BlockchainBlockKernalFetchQuery, + viewType: viewType }, }) : next(new NoDataFoundException()); diff --git a/src/app/view/block-view/block-detail/block-detail.component.html b/src/app/view/block-view/block-detail/block-detail.component.html index ca37ca1..d7a3284 100644 --- a/src/app/view/block-view/block-detail/block-detail.component.html +++ b/src/app/view/block-view/block-detail/block-detail.component.html @@ -1,5 +1,6 @@
-
+
+