commit_id search

This commit is contained in:
shunmugam 2019-09-10 15:38:28 +05:30
parent 56f951b032
commit 9cf293fa0c
2 changed files with 115 additions and 16 deletions

View File

@ -711,6 +711,35 @@ export class BlockchainBlockController {
next: NextFunction,
) => {
try {
var BlockchainOutputFetchQuery = await getConnection(Global.network).getRepository(
BlockchainOutput,
).findOne({
select: [
'BlockId'
],
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({
@ -729,6 +758,19 @@ export class BlockchainBlockController {
],
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());

View File

@ -1,5 +1,6 @@
<div class="view_content py-4">
<div *ngIf="hasdata" class="container">
<div *ngIf="hashdata.viewType == 'HashHeight' " >
<div *ngIf="TimeArr" class="box_shadow_large detail_div p-3 mb-4">
<!-- <h1 class="test_msg align-middle mb-0 d-inline-block mr-3 pl-3">{{'home.HEADER_TEXT' | translate}}</h1> -->
<!-- <h1 class="test_msg align-middle mb-0 float-right d-inline-block pl-3">{{'home.COUNTDOWN' | translate}}
@ -285,6 +286,59 @@
</div>
<div *ngIf="hashdata.viewType == 'Commit'" >
<div class="container">
<h3>&nbsp; Output Commit <span style="font-size:15px"></span></h3>
<table class="table table-horizontal-bordered table-hover">
<tbody>
<tr>
<td>Created at block </td>
<td>{{ hashdata.BlockchainBlockFetchQuery.Height }}</td>
</tr>
<tr>
<td>Created At </td>
<td>{{ hashdata.BlockchainBlockFetchQuery.Timestamp }}</td>
</tr>
<tr>
<td>Output Type</td>
<td>{{ hashdata.BlockchainBlockOutputFetchQuery[0].OutputType }}</td>
</tr>
<tr>
<td>Proof</td>
<td>{{ hashdata.BlockchainBlockOutputFetchQuery[0].Proof }}</td>
</tr>
<tr>
<td>Proof hash</td>
<td>{{ hashdata.BlockchainBlockOutputFetchQuery[0].ProofHash }}</td>
</tr>
<tr>
<td>Merkle Proof</td>
<td>{{ hashdata.BlockchainBlockOutputFetchQuery[0].MerkleProof }}</td>
</tr>
<tr>
<td>MMR Index</td>
<td>{{ hashdata.BlockchainBlockOutputFetchQuery[0].MmrIndex }}</td>
</tr>
</tbody>
</table>
<div *ngIf="hashdata.BlockchainBlockOutputFetchQuery[0].Proof == false" class="alert alert-success" role="alert">
The output commit was not spent.
</div>
</div>
</div>
</div>
<div *ngIf="!hasdata" class="container">