From 78bf2656810581515b47daa487c6531b1a16c6b5 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Tue, 25 Sep 2018 19:13:41 -0700 Subject: [PATCH 1/3] Use getblockchaininfo and format softforks --- node_modules/bitcoin/lib/bitcoin/client.js | 1 + testnet.js | 2 +- views/index.ejs | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/node_modules/bitcoin/lib/bitcoin/client.js b/node_modules/bitcoin/lib/bitcoin/client.js index 10ae6ce..6834151 100644 --- a/node_modules/bitcoin/lib/bitcoin/client.js +++ b/node_modules/bitcoin/lib/bitcoin/client.js @@ -15,6 +15,7 @@ var bitcoinAPI = { getAddressesByAccount: 'getaddressesbyaccount', getBalance: 'getbalance', getBlock: 'getblock', + getBlockchainInfo: 'getblockchaininfo', getBlockCount: 'getblockcount', getBlockHash: 'getblockhash', getConnectionCount: 'getconnectioncount', diff --git a/testnet.js b/testnet.js index 8f5b053..771cec5 100644 --- a/testnet.js +++ b/testnet.js @@ -210,7 +210,7 @@ function Application() { } function update_status() { - self.client.getInfo(function(err, info) { + self.client.getBlockchainInfo(function(err, info) { if(err) console.error("getInfo error:",err); self.status.info = info; diff --git a/views/index.ejs b/views/index.ejs index cab56ee..67b5051 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -68,6 +68,23 @@ function Application() { str = "" _.each(response.info, function(v,n) { str += ""; }) From 311b0e110683c5c19981229ac2ac0dbc363a2a22 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Thu, 27 Sep 2018 18:42:56 -0700 Subject: [PATCH 2/3] Link to testnet.litecore.io (HTTPS) and logic updates --- views/index.ejs | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/views/index.ejs b/views/index.ejs index 67b5051..3e65168 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -58,7 +58,7 @@ function Application() { // --- _.each(response.last_blocks, function(o) { - str += ""+o.height+" - "+o.hash+"
"; + str += ""+o.height+" - "+o.hash+"
"; }); $("#last_blocks").html(str); @@ -69,20 +69,30 @@ function Application() { _.each(response.info, function(v,n) { str += "
"+n+""; + + if (n == "softforks") { + var softforks = ""; + _.each(response.info.softforks, function(softfork) { + softforks += softfork.id + ", "; + }); + v = softforks.substr(0, softforks.length-2); + } + + if (n == "bip9_softforks") { + var bip9softforks = ""; + _.each(response.info.bip9_softforks, function(val, name) { + bip9softforks += name + " (" + val.status + "), "; + }); + v = bip9softforks.substr(0, bip9softforks.length-2); + } + str += v; str += "
"+n+""; - if (n == "softforks") { - var softforks = ""; - _.each(response.info.softforks, function(softfork) { - softforks += softfork.id + ", "; - }); - v = softforks.substr(0, softforks.length-2); - } - - if (n == "bip9_softforks") { - var bip9softforks = ""; - _.each(response.info.bip9_softforks, function(val, name) { - bip9softforks += name + " (" + val.status + "), "; - }); - v = bip9softforks.substr(0, bip9softforks.length-2); + switch (n) { + case "bestblockhash": { + var link = ""+v+" "; + v = link + break; + } + case "softforks": { + var softforks = ""; + _.each(response.info.softforks, function(softfork) { + softforks += softfork.id + ", "; + }); + v = softforks.substr(0, softforks.length-2); + break; + } + case "bip9_softforks": { + var bip9softforks = ""; + _.each(response.info.bip9_softforks, function(val, name) { + bip9softforks += name + " (" + val.status + "), "; + }); + v = bip9softforks.substr(0, bip9softforks.length-2); + break; + } + default: + break; } str += v; From 0eb51132b234923a29c3f37bfc70fad958440fba Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Thu, 27 Sep 2018 18:43:57 -0700 Subject: [PATCH 3/3] Fix DeprecationWarning: 'GLOBAL' --- app.js | 2 +- testnet.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index eb5ca75..04ee736 100644 --- a/app.js +++ b/app.js @@ -94,5 +94,5 @@ function Application() { } -GLOBAL.app = new Application(); +global.app = new Application(); diff --git a/testnet.js b/testnet.js index 771cec5..83eb96c 100644 --- a/testnet.js +++ b/testnet.js @@ -267,7 +267,7 @@ function Application() { dpc(2000, init); } -GLOBAL.app = new Application(); +global.app = new Application(); /*