diff --git a/app.js b/app.js index fb68999..e47ccf2 100755 --- a/app.js +++ b/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) { simpleGit(".").log(["-n 1"], function(err, log) { global.sourcecodeVersion = log.all[0].hash.substring(0, 10); diff --git a/app/coins/btc.js b/app/coins/btc.js index 47681d1..8706cc8 100644 --- a/app/coins/btc.js +++ b/app/coins/btc.js @@ -71,39 +71,29 @@ module.exports = { "time": 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 read more about the genesis block." - } - }, - specialTransactions:{ - "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b":{ - "noteTitle":"This transaction doesn't really exist!", - "noteBodyHtml":"This is the coinbase transaction of the Bitcoin Genesis Block. For more background about this special-case transaction, you can read this brief discussion among some of the Bitcoin developers." - } - }, historicalData: [ { type: "blockheight", date: "2009-01-03", blockHeight: 0, 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 the genesis block.", referenceUrl: "https://en.bitcoin.it/wiki/Genesis_block" }, { type: "tx", date: "2009-01-03", 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 Bitcoin Genesis Block. For more background about this special-case transaction, you can read this brief discussion among some of the Bitcoin developers.", referenceUrl: "https://github.com/bitcoin/bitcoin/issues/3303" }, { type: "tx", date: "2009-10-12", txid: "7dff938918f07619abd38e4510890396b1cef4fbeca154fb7aafba8843295ea2", - note: "First bitcoin traded for fiat currency.", + summary: "First bitcoin traded for fiat currency.", referenceUrl: "https://twitter.com/marttimalmi/status/423455561703624704" }, { @@ -111,35 +101,36 @@ module.exports = { date: "2017-08-24", blockHeight: 481824, blockHash: "0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893", - note: "First SegWit block.", + summary: "First SegWit block.", referenceUrl: "https://twitter.com/conio/status/900722226911219712" }, { type: "tx", date: "2017-08-24", txid: "8f907925d2ebe48765103e6845C06f1f2bb77c6adc1cc002865865eb5cfd5c1c", - note: "First SegWit transaction.", + summary: "First SegWit transaction.", referenceUrl: "https://twitter.com/KHS9NE/status/900553902923362304" }, { type: "tx", date: "2014-06-16", txid: "143a3d7e7599557f9d63e7f224f34d33e9251b2c23c38f95631b3a54de53f024", - note: "Star Wars: A New Hope", + summary: "Star Wars: A New Hope", referenceUrl: "" }, { type: "tx", date: "2010-05-22", 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" }, { type: "tx", date: "2011-05-18", 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/" }, { @@ -147,7 +138,8 @@ module.exports = { date: "2009-01-12", blockHeight: 170, 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" }, { @@ -155,7 +147,7 @@ module.exports = { date: "2017-08-25", blockHeight: 481947, 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/" } ], diff --git a/app/coins/ltc.js b/app/coins/ltc.js index d31694e..f7085be 100644 --- a/app/coins/ltc.js +++ b/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: [ { type: "blockheight", date: "2011-10-07", blockHeight: 0, 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" }, { type: "tx", date: "2017-05-10", txid: "ce385e55fb2a73fa438426145b074f08314812fa3396472dc572b3079e26e0f9", - note: "First SegWit transaction.", + summary: "First SegWit transaction.", referenceUrl: "https://twitter.com/satoshilite/status/862345830082138113" }, { @@ -88,7 +81,7 @@ module.exports = { date: "2011-10-13", blockHeight: 448, blockHash: "6995d69ce2cb7768ef27f55e02dd1772d452deb44e1716bb1dd9c29409edf252", - note: "The first block containing a (non-coinbase) transaction.", + summary: "The first block containing a (non-coinbase) transaction.", referenceUrl: "" }, ], diff --git a/views/fun.pug b/views/fun.pug index 66c5eb3..4bcbe72 100644 --- a/views/fun.pug +++ b/views/fun.pug @@ -21,7 +21,7 @@ block content tr td(class="data-cell") #{item.date} - td(class="data-cell") #{item.note} + td(class="data-cell") #{item.summary} td(class="data-cell monospace") if (item.type == "tx") diff --git a/views/includes/block-content.pug b/views/includes/block-content.pug index 2a9cd08..270941d 100644 --- a/views/includes/block-content.pug +++ b/views/includes/block-content.pug @@ -8,11 +8,28 @@ ul(class='nav nav-tabs mb-3') div(class="tab-content") 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;") - h4(class="alert-heading h5") #{coinConfig.specialBlocks[result.getblock.hash].noteTitle} - if (coinConfig.specialBlocks[result.getblock.hash].noteBodyHtml) - p !{coinConfig.specialBlocks[result.getblock.hash].noteBodyHtml} + h4(class="alert-heading h5") #{coinConfig.name} Fun + + // 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") tr diff --git a/views/transaction.pug b/views/transaction.pug index c012bc4..f60cb00 100644 --- a/views/transaction.pug +++ b/views/transaction.pug @@ -40,11 +40,26 @@ block content div(class="tab-content") 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;") - h4(class="alert-heading h5") #{coinConfig.specialTransactions[txid].noteTitle} - if (coinConfig.specialTransactions[txid].noteBodyHtml) - p !{coinConfig.specialTransactions[txid].noteBodyHtml} + h4(class="alert-heading h5") #{coinConfig.name} Fun + + // 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") tr