Browse Source

Fix #32

fix-133-memory-crash
Dan Janosik 7 years ago
parent
commit
4bc8ffe38c
  1. 14
      app.js
  2. 36
      app/coins/btc.js
  3. 15
      app/coins/ltc.js
  4. 2
      views/fun.pug
  5. 25
      views/includes/block-content.pug
  6. 23
      views/transaction.pug

14
app.js

@ -101,6 +101,20 @@ app.runOnStartup = function() {
}); });
} }
global.specialTransactions = {};
global.specialBlocks = {};
if (global.coinConfig.historicalData) {
global.coinConfig.historicalData.forEach(function(item) {
if (item.type == "blockheight") {
global.specialBlocks[item.blockHash] = item;
} else if (item.type == "tx") {
global.specialTransactions[item.txid] = item;
}
});
}
if (global.sourcecodeVersion == null) { if (global.sourcecodeVersion == null) {
simpleGit(".").log(["-n 1"], function(err, log) { simpleGit(".").log(["-n 1"], function(err, log) {
global.sourcecodeVersion = log.all[0].hash.substring(0, 10); global.sourcecodeVersion = log.all[0].hash.substring(0, 10);

36
app/coins/btc.js

@ -71,39 +71,29 @@ module.exports = {
"time": 1230988505, "time": 1230988505,
"blocktime": 1230988505 "blocktime": 1230988505
}, },
specialBlocks:{
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f":{
"noteTitle":"Bitcoin Genesis Block",
"noteBodyHtml":"This is the first block in the Bitcoin blockchain. This block was mined by Bitcoin's anonymous/pseudonymous creator Satoshi Nakamoto. If you're interested, you can <a href='https://en.bitcoin.it/wiki/Genesis_block'>read more about the genesis block</a>."
}
},
specialTransactions:{
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b":{
"noteTitle":"This transaction doesn't really exist!",
"noteBodyHtml":"This is the coinbase transaction of the <a href='/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'>Bitcoin Genesis Block</a>. For more background about this special-case transaction, you can read <a href='https://github.com/bitcoin/bitcoin/issues/3303'>this brief discussion</a> among some of the <a href='https://bitcoin.org'>Bitcoin</a> developers."
}
},
historicalData: [ historicalData: [
{ {
type: "blockheight", type: "blockheight",
date: "2009-01-03", date: "2009-01-03",
blockHeight: 0, blockHeight: 0,
blockHash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", blockHash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
note: "The bitcoin genesis block.", summary: "The Bitcoin Genesis Block.",
alertBodyHtml: "This is the first block in the Bitcoin blockchain, known as the 'Genesis Block'. This block was mined by Bitcoin's creator Satoshi Nakamoto. You can read more about <a href='https://en.bitcoin.it/wiki/Genesis_block'>the genesis block</a>.",
referenceUrl: "https://en.bitcoin.it/wiki/Genesis_block" referenceUrl: "https://en.bitcoin.it/wiki/Genesis_block"
}, },
{ {
type: "tx", type: "tx",
date: "2009-01-03", date: "2009-01-03",
txid: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", txid: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
note: "The coinbase transaction of the genesis block.", summary: "The coinbase transaction of the Genesis Block.",
alertBodyHtml: "This transaction doesn't really exist! This is the coinbase transaction of the <a href='/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'>Bitcoin Genesis Block</a>. For more background about this special-case transaction, you can read <a href='https://github.com/bitcoin/bitcoin/issues/3303'>this brief discussion</a> among some of the <a href='https://bitcoin.org'>Bitcoin</a> developers.",
referenceUrl: "https://github.com/bitcoin/bitcoin/issues/3303" referenceUrl: "https://github.com/bitcoin/bitcoin/issues/3303"
}, },
{ {
type: "tx", type: "tx",
date: "2009-10-12", date: "2009-10-12",
txid: "7dff938918f07619abd38e4510890396b1cef4fbeca154fb7aafba8843295ea2", txid: "7dff938918f07619abd38e4510890396b1cef4fbeca154fb7aafba8843295ea2",
note: "First bitcoin traded for fiat currency.", summary: "First bitcoin traded for fiat currency.",
referenceUrl: "https://twitter.com/marttimalmi/status/423455561703624704" referenceUrl: "https://twitter.com/marttimalmi/status/423455561703624704"
}, },
{ {
@ -111,35 +101,36 @@ module.exports = {
date: "2017-08-24", date: "2017-08-24",
blockHeight: 481824, blockHeight: 481824,
blockHash: "0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893", blockHash: "0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893",
note: "First SegWit block.", summary: "First SegWit block.",
referenceUrl: "https://twitter.com/conio/status/900722226911219712" referenceUrl: "https://twitter.com/conio/status/900722226911219712"
}, },
{ {
type: "tx", type: "tx",
date: "2017-08-24", date: "2017-08-24",
txid: "8f907925d2ebe48765103e6845C06f1f2bb77c6adc1cc002865865eb5cfd5c1c", txid: "8f907925d2ebe48765103e6845C06f1f2bb77c6adc1cc002865865eb5cfd5c1c",
note: "First SegWit transaction.", summary: "First SegWit transaction.",
referenceUrl: "https://twitter.com/KHS9NE/status/900553902923362304" referenceUrl: "https://twitter.com/KHS9NE/status/900553902923362304"
}, },
{ {
type: "tx", type: "tx",
date: "2014-06-16", date: "2014-06-16",
txid: "143a3d7e7599557f9d63e7f224f34d33e9251b2c23c38f95631b3a54de53f024", txid: "143a3d7e7599557f9d63e7f224f34d33e9251b2c23c38f95631b3a54de53f024",
note: "Star Wars: A New Hope", summary: "Star Wars: A New Hope",
referenceUrl: "" referenceUrl: ""
}, },
{ {
type: "tx", type: "tx",
date: "2010-05-22", date: "2010-05-22",
txid: "a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d", txid: "a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d",
note: "The 'Bitcoin Pizza' transaction.", summary: "The 'Bitcoin Pizza' transaction.",
alertBodyHtml: "This is the famous 'Bitcoin Pizza' transaction.",
referenceUrl: "https://bitcointalk.org/index.php?topic=137.0" referenceUrl: "https://bitcointalk.org/index.php?topic=137.0"
}, },
{ {
type: "tx", type: "tx",
date: "2011-05-18", date: "2011-05-18",
txid: "5d80a29be1609db91658b401f85921a86ab4755969729b65257651bb9fd2c10d", txid: "5d80a29be1609db91658b401f85921a86ab4755969729b65257651bb9fd2c10d",
note: "Destroyed bitcoin.", summary: "Destroyed bitcoin.",
referenceUrl: "https://www.reddit.com/r/Bitcoin/comments/7mhoks/til_in_2011_a_user_running_a_modified_mining/" referenceUrl: "https://www.reddit.com/r/Bitcoin/comments/7mhoks/til_in_2011_a_user_running_a_modified_mining/"
}, },
{ {
@ -147,7 +138,8 @@ module.exports = {
date: "2009-01-12", date: "2009-01-12",
blockHeight: 170, blockHeight: 170,
blockHash: "00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee", blockHash: "00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee",
note: "First block containing a (non-coinbase) transaction.", summary: "First block containing a (non-coinbase) transaction.",
alertBodyHtml: "This block comes 9 days after the genesis block and is the first to contain a transfer of bitcoin. Before this block all blocks contained only coinbase transactions which mint new bitcoin.",
referenceUrl: "https://bitcointalk.org/index.php?topic=91806.msg1012234#msg1012234" referenceUrl: "https://bitcointalk.org/index.php?topic=91806.msg1012234#msg1012234"
}, },
{ {
@ -155,7 +147,7 @@ module.exports = {
date: "2017-08-25", date: "2017-08-25",
blockHeight: 481947, blockHeight: 481947,
blockHash: "00000000000000000139cb443e16442fcd07a4a0e0788dd045ee3cf268982016", blockHash: "00000000000000000139cb443e16442fcd07a4a0e0788dd045ee3cf268982016",
note: "First block mined that was greater than 1MB.", summary: "First block mined that was greater than 1MB.",
referenceUrl: "https://en.bit.news/bitfury-mined-first-segwit-block-size-1-mb/" referenceUrl: "https://en.bit.news/bitfury-mined-first-segwit-block-size-1-mb/"
} }
], ],

15
app/coins/ltc.js

@ -59,28 +59,21 @@ module.exports = {
} }
] ]
}, },
specialBlocks:{
"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2":{
"noteTitle":"Litecoin Genesis Block",
"noteBodyHtml":"This is the first block in the Litecoin blockchain."
}
},
specialTransactions:{
},
historicalData: [ historicalData: [
{ {
type: "blockheight", type: "blockheight",
date: "2011-10-07", date: "2011-10-07",
blockHeight: 0, blockHeight: 0,
blockHash: "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2", blockHash: "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2",
note: "The Litecoin genesis block.", summary: "The Litecoin genesis block.",
alertBodyHtml: "This is the first block in the Litecoin blockchain.",
referenceUrl: "https://medium.com/@SatoshiLite/satoshilite-1e2dad89a017" referenceUrl: "https://medium.com/@SatoshiLite/satoshilite-1e2dad89a017"
}, },
{ {
type: "tx", type: "tx",
date: "2017-05-10", date: "2017-05-10",
txid: "ce385e55fb2a73fa438426145b074f08314812fa3396472dc572b3079e26e0f9", txid: "ce385e55fb2a73fa438426145b074f08314812fa3396472dc572b3079e26e0f9",
note: "First SegWit transaction.", summary: "First SegWit transaction.",
referenceUrl: "https://twitter.com/satoshilite/status/862345830082138113" referenceUrl: "https://twitter.com/satoshilite/status/862345830082138113"
}, },
{ {
@ -88,7 +81,7 @@ module.exports = {
date: "2011-10-13", date: "2011-10-13",
blockHeight: 448, blockHeight: 448,
blockHash: "6995d69ce2cb7768ef27f55e02dd1772d452deb44e1716bb1dd9c29409edf252", blockHash: "6995d69ce2cb7768ef27f55e02dd1772d452deb44e1716bb1dd9c29409edf252",
note: "The first block containing a (non-coinbase) transaction.", summary: "The first block containing a (non-coinbase) transaction.",
referenceUrl: "" referenceUrl: ""
}, },
], ],

2
views/fun.pug

@ -21,7 +21,7 @@ block content
tr tr
td(class="data-cell") #{item.date} td(class="data-cell") #{item.date}
td(class="data-cell") #{item.note} td(class="data-cell") #{item.summary}
td(class="data-cell monospace") td(class="data-cell monospace")
if (item.type == "tx") if (item.type == "tx")

25
views/includes/block-content.pug

@ -8,11 +8,28 @@ ul(class='nav nav-tabs mb-3')
div(class="tab-content") div(class="tab-content")
div(id="tab-summary", class="tab-pane active", role="tabpanel") div(id="tab-summary", class="tab-pane active", role="tabpanel")
if (coinConfig.specialBlocks && coinConfig.specialBlocks[result.getblock.hash]) if (global.specialBlocks && global.specialBlocks[result.getblock.hash])
div(class="alert alert-primary", style="padding-bottom: 0;") div(class="alert alert-primary", style="padding-bottom: 0;")
h4(class="alert-heading h5") #{coinConfig.specialBlocks[result.getblock.hash].noteTitle} h4(class="alert-heading h5") #{coinConfig.name} Fun
if (coinConfig.specialBlocks[result.getblock.hash].noteBodyHtml)
p !{coinConfig.specialBlocks[result.getblock.hash].noteBodyHtml} // special transaction info
- var sbInfo = global.specialBlocks[result.getblock.hash];
if (sbInfo.alertBodyHtml)
p
span !{sbInfo.alertBodyHtml}
if (sbInfo.referenceUrl && sbInfo.referenceUrl.trim().length > 0 && sbInfo.alertBodyHtml.indexOf(sbInfo.referenceUrl) == -1)
span
a(href=sbInfo.referenceUrl) Read more
else
p
span #{sbInfo.summary}
if (sbInfo.referenceUrl && sbInfo.referenceUrl.trim().length > 0)
span
a(href=sbInfo.referenceUrl) Read more
table(class="table") table(class="table")
tr tr

23
views/transaction.pug

@ -40,11 +40,26 @@ block content
div(class="tab-content") div(class="tab-content")
div(id="tab-summary", class="tab-pane active", role="tabpanel") div(id="tab-summary", class="tab-pane active", role="tabpanel")
if (coinConfig.specialTransactions && coinConfig.specialTransactions[txid]) if (global.specialTransactions && global.specialTransactions[txid])
div(class="alert alert-primary", style="padding-bottom: 0;") div(class="alert alert-primary", style="padding-bottom: 0;")
h4(class="alert-heading h5") #{coinConfig.specialTransactions[txid].noteTitle} h4(class="alert-heading h5") #{coinConfig.name} Fun
if (coinConfig.specialTransactions[txid].noteBodyHtml)
p !{coinConfig.specialTransactions[txid].noteBodyHtml} // special transaction info
- var stInfo = global.specialTransactions[txid];
if (stInfo.alertBodyHtml)
p
span !{stInfo.alertBodyHtml}
if (stInfo.referenceUrl && stInfo.referenceUrl.trim().length > 0 && stInfo.alertBodyHtml.indexOf(stInfo.referenceUrl) == -1)
span
a(href=stInfo.referenceUrl) Read more
else
p
span #{stInfo.summary}
if (stInfo.referenceUrl && stInfo.referenceUrl.trim().length > 0)
span
a(href=stInfo.referenceUrl) Read more
table(class="table") table(class="table")
tr tr

Loading…
Cancel
Save