diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index a05a04a..072276c 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -1139,9 +1139,11 @@ export class BlockchainBlockController { var alog_type = TotalDifficultyNBlockRequestData.Type; var Difftype = TotalDifficultyNBlockRequestData.Difftype; if (TotalDifficultyNBlockRequestData.Interval && TotalDifficultyNBlockRequestData.Interval != '1 day') { - var dateFormat = 'YYYY-MM-DD'; + var dateFormat = 'YYYY-MM-DD HH:mm:ss'; + var tickFormat = '%m-%d'; }else{ - var dateFormat = 'HH:mm'; + var dateFormat = 'YYYY-MM-DD HH:mm:ss'; + var tickFormat = '%H-%M'; } if(Difftype == "target"){ var TotalDifficultyNBlockQuery = await getConnection() @@ -1233,7 +1235,8 @@ export class BlockchainBlockController { // DifficultyProgpow: DifficultyProgpow, Maxrange: Maxrange, Minrange: (Minrange * 0.2), - TargetDifficulty: TargetDifficulty + TargetDifficulty: TargetDifficulty, + tickFormat: tickFormat }, }); } catch (error) { diff --git a/server/socket/block.ts b/server/socket/block.ts index ecad358..332b291 100644 --- a/server/socket/block.ts +++ b/server/socket/block.ts @@ -9,8 +9,7 @@ export async function universalGetLatestBlockDetails(socket) { letest_block_duration = ""; const BlockchainLatestBlockQuery = await getConnection().query( - "SELECT timestamp,height,edge_bits,hash,secondary_scaling, previous_id, total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block ORDER BY timestamp DESC LIMIT 1" - ); + "SELECT bb.timestamp,bb.proof,bb.height,bb.edge_bits,bb.hash,bb.secondary_scaling, bb.previous_id, bb.total_difficulty_cuckaroo, bb.total_difficulty_cuckatoo, bb.total_difficulty_progpow, bb.total_difficulty_randomx, COUNT(DISTINCT(bi.block_id)) AS input_count, COUNT(DISTINCT(bk.block_id)) AS kernel_count, COUNT(DISTINCT(bo.block_id)) AS output_count FROM blockchain_block bb LEFT JOIN blockchain_input bi ON bi.block_id = bb.hash LEFT JOIN blockchain_kernel bk ON bk.block_id = bb.hash LEFT JOIN blockchain_output bo ON bo.block_id = bb.hash group by bb.hash, bb.timestamp ORDER BY bb.timestamp DESC LIMIT 1"); const BlockchainPreviousBlockQuery = await getConnection().query( "SELECT total_difficulty_cuckaroo, total_difficulty_cuckatoo, total_difficulty_progpow, total_difficulty_randomx FROM blockchain_block WHERE hash=" + "'" + @@ -132,10 +131,58 @@ export async function universalGetLatestBlockDetails(socket) { BlockchainPreviousBlockQuery[0].total_difficulty_randomx; } + if(BlockchainLatestBlockQuery[0].proof == "RandomX"){ + var Difficulty = targetdifficultyrandomx; + }else if(BlockchainLatestBlockQuery[0].proof == "ProgPow"){ + var Difficulty = targetdifficultyprogpow; + }else if(BlockchainLatestBlockQuery[0].proof == "Cuckoo" ){ + var Difficulty = targetdifficultycuckatoo; + } + block_height = BlockchainLatestBlockQuery[0].height; + + var current_date = new Date(); + // var current_date = new Date("Sat Apr 2 2018 15:04:00 GMT+0530 (IST)"); + + var enddaydif = + Math.abs( + BlockchainLatestBlockQuery[0].timestamp.getTime() - + current_date.getTime(), + ) / + (1000 * 60 * 60 * 24); + var enddayrnd = Math.round(enddaydif); + // if(enddayrnd < 1) { + var millseconds = Math.abs( + BlockchainLatestBlockQuery[0].timestamp.getTime() - + current_date.getTime(), + ); + + var seconds = Math.floor(millseconds / 1000); + var days = Math.floor(seconds / 86400); + var hours = Math.floor((seconds % 86400) / 3600); + var minutes = Math.floor(((seconds % 86400) % 3600) / 60); + seconds = seconds % 60; + var dateTimeDurationString = ''; + + if (days > 0 && (hours === 0 && minutes === 0)) + dateTimeDurationString += days > 1 ? days + 'd ' : days + 'd '; + if (days > 0 && (hours > 0 || minutes > 0)) + dateTimeDurationString += days > 1 ? days + 'd ' : days + 'd '; + if (hours > 0 && minutes > 0) + dateTimeDurationString += hours > 1 ? hours + 'h ' : hours + 'h '; + if (hours > 0 && minutes === 0) + dateTimeDurationString += hours > 1 ? hours + 'h ' : hours + 'h '; + if (minutes > 0) + dateTimeDurationString += minutes > 1 ? minutes + 'm ' : minutes + 'm '; + if (seconds > 0) + dateTimeDurationString += seconds > 1 ? seconds + 's ' : seconds + 's '; + var TotalCuckoo = parseInt(BlockchainLatestBlockQuery[0].total_difficulty_cuckatoo) + parseInt(BlockchainLatestBlockQuery[0].total_difficulty_cuckaroo); + let balance = BlockchainLatestBlockQuery[0].hash.substring(2, 62); + let arr = balance.match(/.{1,6}/g); + var hasharray = arr.map(i => '#' + i); socket.emit("latestblockdetail", { block_height, @@ -149,6 +196,15 @@ export async function universalGetLatestBlockDetails(socket) { targetdifficultyprogpow, targetdifficultyrandomx, TotalCuckoo, + age : dateTimeDurationString, + input_count: BlockchainLatestBlockQuery[0].input_count, + kernel_count: BlockchainLatestBlockQuery[0].kernel_count, + output_count: BlockchainLatestBlockQuery[0].output_count, + proof: BlockchainLatestBlockQuery[0].proof, + hasharray: hasharray, + Difficulty: Difficulty, + hashstart:BlockchainLatestBlockQuery[0].hash.slice(0, 2), + hashend:BlockchainLatestBlockQuery[0].hash.slice(62,64), TotalDifficultyCuckaroo: BlockchainLatestBlockQuery[0].total_difficulty_cuckaroo, TotalDifficultyCuckatoo: diff --git a/src/app/shared/components/header/header.component.html b/src/app/shared/components/header/header.component.html index da90c37..100de3e 100755 --- a/src/app/shared/components/header/header.component.html +++ b/src/app/shared/components/header/header.component.html @@ -41,7 +41,7 @@ - diff --git a/src/app/shared/components/siteheader/siteheader.component.html b/src/app/shared/components/siteheader/siteheader.component.html index 1a91a37..c724c92 100644 --- a/src/app/shared/components/siteheader/siteheader.component.html +++ b/src/app/shared/components/siteheader/siteheader.component.html @@ -13,10 +13,10 @@ @@ -36,7 +36,7 @@ @@ -248,7 +249,7 @@
-
+
User Agent
{{ peer.user_agent }}
@@ -279,8 +280,8 @@
- + - \ No newline at end of file + diff --git a/src/app/view/home/latestblocks/latestblocks.component.ts b/src/app/view/home/latestblocks/latestblocks.component.ts index 0d966d8..e9c981e 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.ts +++ b/src/app/view/home/latestblocks/latestblocks.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewContainerRef, ViewChild,ComponentFactoryResolver} from '@angular/core'; import { HttpClient, HttpParams, HttpErrorResponse, HttpHeaders } from '@angular/common/http'; import { ChartService } from '../../../shared/services/chart.service'; import { FormGroup, FormControl } from '@angular/forms'; import { TransServiceService } from '../../../shared/services/trans-service.service'; import { map, catchError } from 'rxjs/operators'; import { throwError} from 'rxjs'; +import { BlockAppendComponent } from '../block-append/block-append.component'; @Component({ selector: 'epic-explorer-latestblocks', @@ -14,21 +15,28 @@ import { throwError} from 'rxjs'; export class LatestblocksComponent implements OnInit { public hashvalues: any; public pagedata: any = []; + public blockAppend: any; + public blockdetails: any; + public lastblock: any; public clickValue: any; public clickPeer: any; public beforeClick: boolean = false; public clickonMobile: boolean = true; public peers: any; - + paginationForm = new FormGroup({ pagesize: new FormControl(20), }); - constructor(private chartService: ChartService,public translate: TransServiceService,public http: HttpClient) {} + @ViewChild('block', { read: ViewContainerRef,static: true }) block: ViewContainerRef; + + + constructor(private chartService: ChartService,public translate: TransServiceService,public http: HttpClient, private resolver: ComponentFactoryResolver) {} ngOnInit() { this. getpeersList(); this.gettinghashList(1, 20); + this.getLastCeatedBlock(); } public gettinghashList(CurrentPage, PageSize) { @@ -46,6 +54,41 @@ export class LatestblocksComponent implements OnInit { ); } + getLastCeatedBlock() { + this.chartService.getLatestblockdetails().subscribe(response => { + this.blockdetails = response; + console.log(this.blockdetails); + if (this.lastblock != this.blockdetails.block_height) { + console.log('Create'); + this.createBlock(); + } + this.lastblock = this.blockdetails.block_height; + }); + } + + public createBlock() { + const blockFactory = this.resolver.resolveComponentFactory( + BlockAppendComponent, + ); + const block = this.block.createComponent(blockFactory); + this.blockAppend = {}; + this.blockAppend['blockchain_block_hash'] = this.blockdetails.hash; + this.blockAppend[ + 'blockchain_block_height' + ] = this.blockdetails.block_height; + this.blockAppend['age'] = this.blockdetails.age; + this.blockAppend['target_difficulty'] = this.blockdetails.Difficulty; + this.blockAppend['PoWAlgo'] = this.blockdetails.proof; + this.blockAppend['input_count'] = this.blockdetails.input_count; + this.blockAppend['output_count'] = this.blockdetails.output_count; + this.blockAppend['kernal_count'] = this.blockdetails.kernel_count; + this.blockAppend['hashstart'] = this.blockdetails.hashstart; + this.blockAppend['hashend'] = this.blockdetails.hashend; + this.blockAppend['hasharray'] = this.blockdetails.hasharray; + + block.instance.blockdetails = this.blockAppend; + } + public getpeersList() { this.chartService.apiGetRequest('','/blockchain_kernel/getpeers').subscribe( res => { @@ -58,7 +101,7 @@ export class LatestblocksComponent implements OnInit { // this.peers = [{"id": 1,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"54.233.177.64:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 2,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"95.216.102.217:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 3,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"90.190.172.177:3414","direction":"Outbound","total_difficulty":{"cuckaroo":2,"cuckatoo":2,"randomx":1024,"progpow":256},"height":0},{"id": 4,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"67.189.82.196:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10},{"id": 5,"capabilities":{"bits":15},"user_agent":"MW/Epic 1.0.0","version":1,"addr":"167.71.72.2:3414","direction":"Outbound","total_difficulty":{"cuckaroo":1630,"cuckatoo":706,"randomx":138024,"progpow":49792},"height":10}]; } - + public onClickPlus(height) { // this.beforeClick = true; diff --git a/src/assets/css/style.css b/src/assets/css/style.css index ceeaa84..081bab8 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -286,6 +286,7 @@ a:focus { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); padding: 20px; transition: 0.3s linear all; + min-height: 100%; } .detail_div .count { font-size: 25px; @@ -645,7 +646,14 @@ body.dark_theme { .dark_theme .view_content table{border-color: #384566;} .dark_theme .card-body{background-color: #1c2437;} .diff_margin{margin-bottom: -10px !important; margin-top: -10px !important;} - +@keyframes yellowfade { + from { + background: yellow; + } + to { + background: transparent; + } +} .item-highlight { animation: yellowfade 5s ; -moz-animation: yellowfade 5s ;