From 3d9cf6c29270a877a606a6222b04b94f171f4c5d Mon Sep 17 00:00:00 2001 From: "raja.blaze" Date: Fri, 16 Aug 2019 18:36:07 +0530 Subject: [PATCH] Peer url updated --- server/controllers/BlockchainKernel.ts | 7 ++++++- server/middlewares/validator.middleware.ts | 6 +++++- .../view/home/latestblocks/latestblocks.component.ts | 12 ++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/controllers/BlockchainKernel.ts b/server/controllers/BlockchainKernel.ts index c42b414..f8d0c55 100644 --- a/server/controllers/BlockchainKernel.ts +++ b/server/controllers/BlockchainKernel.ts @@ -559,7 +559,12 @@ export class BlockchainKernelController { ) => { var self = this; try { - http.get('http://116.203.152.58:13413/v1/peers/connected', + if(Global.network == "Floonet"){ + var peer_url = process.env.FLOONET_PEER_URL; + }else{ + var peer_url = process.env.TESTNET_PEER_URL; + } + http.get(peer_url, async (resp) => { // console.log('resp resp respresp',resp); let data = ''; diff --git a/server/middlewares/validator.middleware.ts b/server/middlewares/validator.middleware.ts index dc2d6c8..7281455 100644 --- a/server/middlewares/validator.middleware.ts +++ b/server/middlewares/validator.middleware.ts @@ -10,7 +10,11 @@ export function validationMiddleware( skipMissingProperties = false, ): express.RequestHandler { return (request: Request, response: Response, next: NextFunction) => { - Global.network = request.headers.network; + if(request.headers.network){ + Global.network = request.headers.network; + }else{ + Global.network = 'Floonet'; + } validate( plainToClass(type, { ...request.body, diff --git a/src/app/view/home/latestblocks/latestblocks.component.ts b/src/app/view/home/latestblocks/latestblocks.component.ts index 8951c06..d95beb2 100644 --- a/src/app/view/home/latestblocks/latestblocks.component.ts +++ b/src/app/view/home/latestblocks/latestblocks.component.ts @@ -101,9 +101,17 @@ export class LatestblocksComponent implements OnInit { if (res['status'] == 200) { let json = res.response.dataJson; if(json && json.length > 0){ - localStorage.setItem('peersJson',JSON.stringify(json)); + if(localStorage.getItem('network') == "Testnet"){ + localStorage.setItem('peersJson_Testnet',JSON.stringify(json)); + }else{ + localStorage.setItem('peersJson_Floonet',JSON.stringify(json)); + } + } + if(localStorage.getItem('network') == "Testnet"){ + this.peers = JSON.parse(localStorage.getItem('peersJson_Testnet')); + }else{ + this.peers = JSON.parse(localStorage.getItem('peersJson_Floonet')); } - this.peers = JSON.parse(localStorage.getItem('peersJson')); } }, error => {},