Browse Source

Nicer HTML and version info in AZ.

cl-refactor
Gav Wood 10 years ago
parent
commit
abd800ffbc
  1. 94
      alethzero/MainWin.cpp
  2. 8
      libethcore/Common.cpp
  3. 3
      libethcore/Common.h

94
alethzero/MainWin.cpp

@ -1059,8 +1059,7 @@ void Main::refreshBlockCount()
{ {
cwatch << "refreshBlockCount()"; cwatch << "refreshBlockCount()";
auto d = ethereum()->blockChain().details(); auto d = ethereum()->blockChain().details();
auto diff = BlockInfo(ethereum()->blockChain().block()).difficulty; ui->blockCount->setText(QString("%4 #%1 PV%2 D%3 H%5").arg(d.number).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet").arg(c_ethashVersion));
ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet"));
} }
void Main::on_turboMining_triggered() void Main::on_turboMining_triggered()
@ -1429,63 +1428,64 @@ void Main::on_blocks_currentItemChanged()
s << "<h3>" << h << "</h3>"; s << "<h3>" << h << "</h3>";
s << "<h4>#" << info.number; s << "<h4>#" << info.number;
s << "&nbsp;&emsp;&nbsp;<b>" << timestamp << "</b></h4>"; s << "&nbsp;&emsp;&nbsp;<b>" << timestamp << "</b></h4>";
s << "<br/>D/TD: <b>" << info.difficulty << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty); s << "<div>D/TD: <b>" << info.difficulty << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty) << "</div>";
s << "&nbsp;&emsp;&nbsp;Children: <b>" << details.children.size() << "</b></h5>"; s << "&nbsp;&emsp;&nbsp;Children: <b>" << details.children.size() << "</b></div>";
s << "<br/>Gas used/limit: <b>" << info.gasUsed << "</b>/<b>" << info.gasLimit << "</b>"; s << "<div>Gas used/limit: <b>" << info.gasUsed << "</b>/<b>" << info.gasLimit << "</b>" << "</div>";
s << "<br/>Coinbase: <b>" << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << "</b> " << info.coinbaseAddress; s << "<div>Benefactor: <b>" << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress << "</b>" << "</div>";
s << "<br/>Seed hash: <b>" << info.seedHash() << "</b>"; s << "<div>Seed hash: <b>" << info.seedHash() << "</b>" << "</div>";
s << "<br/>Mix hash: <b>" << info.mixHash << "</b>"; s << "<div>Mix hash: <b>" << info.mixHash << "</b>" << "</div>";
s << "<br/>Nonce: <b>" << info.nonce << "</b>"; s << "<div>Nonce: <b>" << info.nonce << "</b>" << "</div>";
s << "<br/>Hash w/o nonce: <b>" << info.headerHash(WithoutNonce) << "</b>"; s << "<div>Hash w/o nonce: <b>" << info.headerHash(WithoutNonce) << "</b>" << "</div>";
s << "<br/>Difficulty: <b>" << info.difficulty << "</b>"; s << "<div>Difficulty: <b>" << info.difficulty << "</b>" << "</div>";
if (info.number) if (info.number)
{ {
auto e = Ethasher::eval(info); auto e = Ethasher::eval(info);
s << "<br/>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")"; s << "<div>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << "<br/>Parent: <b>" << info.parentHash << "</b>"; s << "<div>Parent: <b>" << info.parentHash << "</b>" << "</div>";
} }
else else
{ {
s << "<br/>Proof-of-Work: <i>Phil has nothing to prove</i>"; s << "<div>Proof-of-Work: <b><i>Phil has nothing to prove</i></b></div>";
s << "<br/>Parent: <i>It was a virgin birth</i>"; s << "<div>Parent: <b><i>It was a virgin birth</i></b></div>";
} }
// s << "<br/>Bloom: <b>" << details.bloom << "</b>"; // s << "<div>Bloom: <b>" << details.bloom << "</b>";
if (!!info.logBloom) if (!!info.logBloom)
s << "<div>Log Bloom: " << info.logBloom << "</div>"; s << "<div>Log Bloom: " << info.logBloom << "</div>";
else else
s << "<div>Log Bloom: <i>Uneventful</i></div>"; s << "<div>Log Bloom: <i>Uneventful</i></div>";
s << "<br/>Transactions: <b>" << block[1].itemCount() << "</b> @<b>" << info.transactionsRoot << "</b>"; s << "<div>Transactions: <b>" << block[1].itemCount() << "</b> @<b>" << info.transactionsRoot << "</b>" << "</div>";
s << "<br/>Receipts: @<b>" << info.receiptsRoot << "</b>:"; s << "<div>Uncles: <b>" << block[2].itemCount() << "</b> @<b>" << info.sha3Uncles << "</b>" << "</div>";
s << "<br/>Uncles: <b>" << block[2].itemCount() << "</b> @<b>" << info.sha3Uncles << "</b>";
for (auto u: block[2]) for (auto u: block[2])
{ {
BlockInfo uncle = BlockInfo::fromHeader(u.data()); BlockInfo uncle = BlockInfo::fromHeader(u.data());
char const* line = "<br/><span style=\"margin-left: 2em\">&nbsp;</span>"; char const* line = "<div><span style=\"margin-left: 2em\">&nbsp;</span>";
s << line << "Hash: <b>" << uncle.hash << "</b>"; s << line << "Hash: <b>" << uncle.hash << "</b>" << "</div>";
s << line << "Parent: <b>" << uncle.parentHash << "</b>"; s << line << "Parent: <b>" << uncle.parentHash << "</b>" << "</div>";
s << line << "Number: <b>" << uncle.number << "</b>"; s << line << "Number: <b>" << uncle.number << "</b>" << "</div>";
s << line << "Coinbase: <b>" << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << "</b> " << uncle.coinbaseAddress; s << line << "Coinbase: <b>" << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress << "</b>" << "</div>";
s << line << "Seed hash: <b>" << uncle.seedHash() << "</b>"; s << line << "Seed hash: <b>" << uncle.seedHash() << "</b>" << "</div>";
s << line << "Mix hash: <b>" << uncle.mixHash << "</b>"; s << line << "Mix hash: <b>" << uncle.mixHash << "</b>" << "</div>";
s << line << "Nonce: <b>" << uncle.nonce << "</b>"; s << line << "Nonce: <b>" << uncle.nonce << "</b>" << "</div>";
s << line << "Hash w/o nonce: <b>" << uncle.headerHash(WithoutNonce) << "</b>"; s << line << "Hash w/o nonce: <b>" << uncle.headerHash(WithoutNonce) << "</b>" << "</div>";
s << line << "Difficulty: <b>" << uncle.difficulty << "</b>"; s << line << "Difficulty: <b>" << uncle.difficulty << "</b>" << "</div>";
auto e = Ethasher::eval(uncle); auto e = Ethasher::eval(uncle);
s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")"; s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
} }
if (info.parentHash) if (info.parentHash)
s << "<br/>Pre: <b>" << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "</b>"; s << "<div>Pre: <b>" << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "</b>" << "</div>";
else else
s << "<br/>Pre: <i>Nothing is before Phil</i>"; s << "<div>Pre: <b><i>Nothing is before Phil</i></b>" << "</div>";
s << "<div>Receipts: @<b>" << info.receiptsRoot << "</b>:" << "</div>";
BlockReceipts receipts = ethereum()->blockChain().receipts(h); BlockReceipts receipts = ethereum()->blockChain().receipts(h);
unsigned ii = 0; unsigned ii = 0;
for (auto const& i: block[1]) for (auto const& i: block[1])
{ {
s << "<br/>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]"; s << "<div>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]" << "</div>";
++ii; ++ii;
} }
s << "<br/>Post: <b>" << info.stateRoot << "</b>"; s << "<div>Post: <b>" << info.stateRoot << "</b>" << "</div>";
s << "<br/>Dump: " Span(Mono) << toHex(block[0].data()) << "</span>"; s << "<div>Dump: " Span(Mono) << toHex(block[0].data()) << "</span>" << "</div>";
s << "<div>Receipts-Hex: " Span(Mono) << toHex(receipts.rlp()) << "</span></div>"; s << "<div>Receipts-Hex: " Span(Mono) << toHex(receipts.rlp()) << "</span></div>";
} }
else else
@ -1497,19 +1497,19 @@ void Main::on_blocks_currentItemChanged()
TransactionReceipt receipt = ethereum()->blockChain().receipts(h).receipts[txi]; TransactionReceipt receipt = ethereum()->blockChain().receipts(h).receipts[txi];
s << "<h3>" << th << "</h3>"; s << "<h3>" << th << "</h3>";
s << "<h4>" << h << "[<b>" << txi << "</b>]</h4>"; s << "<h4>" << h << "[<b>" << txi << "</b>]</h4>";
s << "<br/>From: <b>" << pretty(ss).toHtmlEscaped().toStdString() << "</b> " << ss; s << "<div>From: <b>" << pretty(ss).toHtmlEscaped().toStdString() << " " << ss << "</b>" << "</div>";
if (tx.isCreation()) if (tx.isCreation())
s << "<br/>Creates: <b>" << pretty(right160(th)).toHtmlEscaped().toStdString() << "</b> " << right160(th); s << "<div>Creates: <b>" << pretty(right160(th)).toHtmlEscaped().toStdString() << "</b> " << right160(th) << "</div>";
else else
s << "<br/>To: <b>" << pretty(tx.receiveAddress()).toHtmlEscaped().toStdString() << "</b> " << tx.receiveAddress(); s << "<div>To: <b>" << pretty(tx.receiveAddress()).toHtmlEscaped().toStdString() << "</b> " << tx.receiveAddress() << "</div>";
s << "<br/>Value: <b>" << formatBalance(tx.value()) << "</b>"; s << "<div>Value: <b>" << formatBalance(tx.value()) << "</b>" << "</div>";
s << "&nbsp;&emsp;&nbsp;#<b>" << tx.nonce() << "</b>"; s << "&nbsp;&emsp;&nbsp;#<b>" << tx.nonce() << "</b>" << "</div>";
s << "<br/>Gas price: <b>" << formatBalance(tx.gasPrice()) << "</b>"; s << "<div>Gas price: <b>" << formatBalance(tx.gasPrice()) << "</b>" << "</div>";
s << "<br/>Gas: <b>" << tx.gas() << "</b>"; s << "<div>Gas: <b>" << tx.gas() << "</b>" << "</div>";
s << "<br/>V: <b>" << hex << nouppercase << (int)tx.signature().v << " + 27</b>"; s << "<div>V: <b>" << hex << nouppercase << (int)tx.signature().v << " + 27</b>" << "</div>";
s << "<br/>R: <b>" << hex << nouppercase << tx.signature().r << "</b>"; s << "<div>R: <b>" << hex << nouppercase << tx.signature().r << "</b>" << "</div>";
s << "<br/>S: <b>" << hex << nouppercase << tx.signature().s << "</b>"; s << "<div>S: <b>" << hex << nouppercase << tx.signature().s << "</b>" << "</div>";
s << "<br/>Msg: <b>" << tx.sha3(eth::WithoutSignature) << "</b>"; s << "<div>Msg: <b>" << tx.sha3(eth::WithoutSignature) << "</b>" << "</div>";
if (!tx.data().empty()) if (!tx.data().empty())
{ {
if (tx.isCreation()) if (tx.isCreation())
@ -1522,7 +1522,7 @@ void Main::on_blocks_currentItemChanged()
if (!!receipt.bloom()) if (!!receipt.bloom())
s << "<div>Log Bloom: " << receipt.bloom() << "</div>"; s << "<div>Log Bloom: " << receipt.bloom() << "</div>";
else else
s << "<div>Log Bloom: <i>Uneventful</i></div>"; s << "<div>Log Bloom: <b><i>Uneventful</i></b></div>";
auto r = receipt.rlp(); auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>"; s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>"; s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";

8
libethcore/Common.cpp

@ -22,6 +22,7 @@
#include "Common.h" #include "Common.h"
#include <random> #include <random>
#include <libdevcrypto/SHA3.h> #include <libdevcrypto/SHA3.h>
#include "Ethasher.h"
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
@ -32,15 +33,16 @@ namespace dev
namespace eth namespace eth
{ {
const unsigned c_ethashVersion = c_ethashRevision;
const unsigned c_protocolVersion = 58; const unsigned c_protocolVersion = 58;
const unsigned c_databaseBaseVersion = 9; const unsigned c_databaseBaseVersion = 8;
#if ETH_FATDB #if ETH_FATDB
const unsigned c_databaseVersionModifier = 1000; const unsigned c_databaseVersionModifier = 1;
#else #else
const unsigned c_databaseVersionModifier = 0; const unsigned c_databaseVersionModifier = 0;
#endif #endif
const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; const unsigned c_databaseVersion = c_databaseBaseVersion + (c_databaseVersionModifier << 8) + (c_ethashVersion << 9);
vector<pair<u256, string>> const& units() vector<pair<u256, string>> const& units()
{ {

3
libethcore/Common.h

@ -38,6 +38,9 @@ extern const unsigned c_protocolVersion;
/// Current database version. /// Current database version.
extern const unsigned c_databaseVersion; extern const unsigned c_databaseVersion;
/// Current database version.
extern const unsigned c_ethashVersion;
/// User-friendly string representation of the amount _b in wei. /// User-friendly string representation of the amount _b in wei.
std::string formatBalance(bigint const& _b); std::string formatBalance(bigint const& _b);

Loading…
Cancel
Save