Merge branch 'master' into randomx

This commit is contained in:
moneroexamples 2019-06-17 16:36:40 +08:00
commit ae1af46490
7 changed files with 60 additions and 37 deletions

View File

@ -34,6 +34,7 @@ Clearnet versions:
- [http://monerochain.com/](http://monerochain.com/) - JSON API based, multiple nodes.
- [https://blox.minexmr.com/](https://blox.minexmr.com/) - - https enabled.
- [https://community.xmr.to/explorer/mainnet/](https://community.xmr.to/explorer/mainnet/)
- [https://exp.xmr.sk/](https://exp.xmr.sk/)
Testnet version:
@ -92,30 +93,17 @@ Note: `devel` branch of the explorer follows `master` branch of the monero.
## Compilation on Ubuntu 16.04/18.04
##### Compile latest Monero version (0.14.0.2)
Download and compile recent Monero into your home folder:
#### Monero download and compilation
```bash
# first install monero dependecines
sudo apt update
To download and compile recent Monero follow instructions
in the following link:
sudo apt install git build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libcurl4-openssl-dev libgtest-dev libreadline-dev libzmq3-dev libsodium-dev libhidapi-dev libhidapi-libusb0
# go to home folder
cd ~
# download monero sourced for master branch
git clone --recursive https://github.com/monero-project/monero.git
cd monero/
USE_SINGLE_BUILDDIR=1 make
```
https://github.com/moneroexamples/monero-compilation/blob/master/README.md
##### Compile and run the explorer
Once the Monero is compiles, the explorer can be downloaded and compiled
Once the Monero compiles, the explorer can be downloaded and compiled
as follows:
```bash
@ -134,12 +122,6 @@ mkdir build && cd build
# create the makefile
cmake ..
# altearnatively can use: cmake -DMONERO_DIR=/path/to/monero_folder ..
# if monero is not in ~/monero
#
# also can build with ASAN (sanitizers), for example
# cmake -DSANITIZE_ADDRESS=On ..
# compile
make
```

View File

@ -275,8 +275,11 @@ MempoolStatus::read_network_info()
local_copy.height = rpc_network_info.height;
local_copy.target_height = rpc_network_info.target_height;
local_copy.difficulty = rpc_network_info.difficulty;
local_copy.difficulty_top64 = rpc_network_info.difficulty_top64;
local_copy.target = rpc_network_info.target;
local_copy.hash_rate = (rpc_network_info.difficulty/rpc_network_info.target);
cryptonote::difficulty_type hash_rate = cryptonote::difficulty_type(rpc_network_info.wide_difficulty) / rpc_network_info.target;
local_copy.hash_rate = (hash_rate & 0xFFFFFFFFFFFFFFFF).convert_to<uint64_t>();
local_copy.hash_rate_top64 = ((hash_rate >> 64) & 0xFFFFFFFFFFFFFFFF).convert_to<uint64_t>();
local_copy.tx_count = rpc_network_info.tx_count;
local_copy.tx_pool_size = rpc_network_info.tx_pool_size;
local_copy.alt_blocks_count = rpc_network_info.alt_blocks_count;
@ -286,6 +289,7 @@ MempoolStatus::read_network_info()
local_copy.nettype = rpc_network_info.testnet ? cryptonote::network_type::TESTNET :
rpc_network_info.stagenet ? cryptonote::network_type::STAGENET : cryptonote::network_type::MAINNET;
local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty;
local_copy.cumulative_difficulty_top64 = rpc_network_info.cumulative_difficulty_top64;
local_copy.block_size_limit = rpc_network_info.block_size_limit;
local_copy.block_size_median = rpc_network_info.block_size_median;
local_copy.block_weight_limit = rpc_network_info.block_weight_limit;

View File

@ -61,6 +61,7 @@ struct MempoolStatus
uint64_t height {0};
uint64_t target_height {0};
uint64_t difficulty {0};
uint64_t difficulty_top64 {0};
uint64_t target {0};
uint64_t tx_count {0};
uint64_t tx_pool_size {0};
@ -72,6 +73,7 @@ struct MempoolStatus
cryptonote::network_type nettype {cryptonote::network_type::MAINNET};
crypto::hash top_block_hash;
uint64_t cumulative_difficulty {0};
uint64_t cumulative_difficulty_top64 {0};
uint64_t block_size_limit {0};
uint64_t block_size_median {0};
uint64_t block_weight_limit {0};
@ -81,6 +83,7 @@ struct MempoolStatus
uint64_t current_hf_version {0};
uint64_t hash_rate {0};
uint64_t hash_rate_top64 {0};
uint64_t fee_per_kb {0};
uint64_t info_timestamp {0};

View File

@ -935,13 +935,15 @@ index2(uint64_t page_no = 0, bool refresh_page = false)
// perapre network info mstch::map for the front page
string hash_rate;
double hr_d;
char metric_prefix;
cryptonote::difficulty_type hr = make_difficulty(current_network_info.hash_rate, current_network_info.hash_rate_top64);
get_metric_prefix(hr, hr_d, metric_prefix);
if (current_network_info.hash_rate > 1e6)
hash_rate = fmt::format("{:0.3f} MH/s", current_network_info.hash_rate/1.0e6);
else if (current_network_info.hash_rate > 1e3)
hash_rate = fmt::format("{:0.3f} kH/s", current_network_info.hash_rate/1.0e3);
if (metric_prefix != 0)
hash_rate = fmt::format("{:0.3f} {:c}H/s", hr_d, metric_prefix);
else
hash_rate = fmt::format("{:d} H/s", current_network_info.hash_rate);
hash_rate = fmt::format("{:s} H/s", hr.str());
pair<string, string> network_info_age = get_age(local_copy_server_timestamp,
current_network_info.info_timestamp);
@ -954,7 +956,7 @@ index2(uint64_t page_no = 0, bool refresh_page = false)
}
context["network_info"] = mstch::map {
{"difficulty" , current_network_info.difficulty},
{"difficulty" , make_difficulty(current_network_info.difficulty, current_network_info.difficulty_top64).str()},
{"hash_rate" , hash_rate},
{"fee_per_kb" , print_money(current_network_info.fee_per_kb)},
{"alt_blocks_no" , current_network_info.alt_blocks_count},
@ -1322,8 +1324,7 @@ show_block(uint64_t _blk_height)
{"blk_nonce" , blk.nonce},
{"blk_pow_hash" , blk_pow_hash_str},
{"is_randomx" , (blk.major_version >= 12)},
{"blk_difficulty_lo" , (blk_difficulty << 64 >> 64).convert_to<uint64_t>()},
{"blk_difficulty_hi" , (blk_difficulty >> 64).convert_to<uint64_t>()},
{"blk_difficulty" , blk_difficulty.str()},
{"age_format" , age.second},
{"major_ver" , std::to_string(blk.major_version)},
{"minor_ver" , std::to_string(blk.minor_version)},
@ -7050,7 +7051,7 @@ get_monero_network_info(json& j_info)
{"current" , local_copy_network_info.current},
{"height" , local_copy_network_info.height},
{"target_height" , local_copy_network_info.target_height},
{"difficulty" , local_copy_network_info.difficulty},
{"difficulty" , make_difficulty(local_copy_network_info.difficulty, local_copy_network_info.difficulty_top64).str()},
{"target" , local_copy_network_info.target},
{"hash_rate" , local_copy_network_info.hash_rate},
{"tx_count" , local_copy_network_info.tx_count},
@ -7063,7 +7064,7 @@ get_monero_network_info(json& j_info)
{"testnet" , local_copy_network_info.nettype == cryptonote::network_type::TESTNET},
{"stagenet" , local_copy_network_info.nettype == cryptonote::network_type::STAGENET},
{"top_block_hash" , pod_to_hex(local_copy_network_info.top_block_hash)},
{"cumulative_difficulty" , local_copy_network_info.cumulative_difficulty},
{"cumulative_difficulty" , make_difficulty(local_copy_network_info.cumulative_difficulty, local_copy_network_info.cumulative_difficulty_top64).str()},
{"block_size_limit" , local_copy_network_info.block_size_limit},
{"block_size_median" , local_copy_network_info.block_size_median},
{"start_time" , local_copy_network_info.start_time},

View File

@ -32,14 +32,14 @@
</tr>
<tr>
<td>PoW hash:</td><td>{{blk_pow_hash}}</td>
<td>Difficulty (hi64, lo64):</td><td>{{blk_difficulty_hi}}, {{blk_difficulty_lo}}</td>
<td>Difficulty:</td><td>{{blk_difficulty}}</td>
{{#is_randomx}}
<td colspan="2"><a href="/randomx/{{blk_height}}">RandomX source code</a></td>
{{/is_randomx}}
{{^is_randomx}}
<td></td>
{{/is_randomx}}
<td></td>
</tr>
</table>

View File

@ -1272,4 +1272,31 @@ tx_to_hex(transaction const& tx)
return epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(tx));
}
void get_metric_prefix(cryptonote::difficulty_type hr, double& hr_d, char& prefix)
{
if (hr < 1000)
{
prefix = 0;
return;
}
static const char metric_prefixes[4] = { 'k', 'M', 'G', 'T' };
for (size_t i = 0; i < sizeof(metric_prefixes); ++i)
{
if (hr < 1000000)
{
hr_d = hr.convert_to<double>() / 1000;
prefix = metric_prefixes[i];
return;
}
hr /= 1000;
}
prefix = 0;
}
cryptonote::difficulty_type
make_difficulty(uint64_t low, uint64_t high)
{
return (cryptonote::difficulty_type(high) << 64) + low;
}
}

View File

@ -373,6 +373,12 @@ pause_execution(uint64_t no_seconds, const string& text = "now");
string
tx_to_hex(transaction const& tx);
void
get_metric_prefix(cryptonote::difficulty_type hr, double& hr_d, char& prefix);
cryptonote::difficulty_type
make_difficulty(uint64_t low, uint64_t high);
}
#endif //XMREG01_TOOLS_H