mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-16 07:47:40 +00:00
Show all Monero block rewards in log
This commit is contained in:
parent
75843e9b37
commit
5d6fa03f11
5 changed files with 39 additions and 16 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
build
|
build
|
||||||
|
logs
|
||||||
|
|
|
@ -221,9 +221,9 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
||||||
|
|
||||||
const uint64_t max_reward = base_reward + total_tx_fees;
|
const uint64_t max_reward = base_reward + total_tx_fees;
|
||||||
|
|
||||||
LOGINFO(3, "base reward = " << log::Gray() << base_reward << log::NoColor() <<
|
LOGINFO(3, "base reward = " << log::Gray() << log::XMRAmount(base_reward) << log::NoColor() <<
|
||||||
", mempool: " << log::Gray() << m_mempoolTxs.size() << log::NoColor() <<
|
", mempool: " << log::Gray() << m_mempoolTxs.size() << log::NoColor() <<
|
||||||
" transactions, fees = " << log::Gray() << total_tx_fees << log::NoColor() <<
|
" transactions, fees = " << log::Gray() << log::XMRAmount(total_tx_fees) << log::NoColor() <<
|
||||||
", weight = " << log::Gray() << total_tx_weight);
|
", weight = " << log::Gray() << total_tx_weight);
|
||||||
|
|
||||||
m_blockHeader.clear();
|
m_blockHeader.clear();
|
||||||
|
@ -384,11 +384,11 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TEST_MEMPOOL_PICKING_ALGORITHM
|
#if TEST_MEMPOOL_PICKING_ALGORITHM
|
||||||
LOGINFO(3, "final_reward = " << final_reward << ", transactions = " << m_numTransactionHashes << ", final_weight = " << final_weight);
|
LOGINFO(3, "final_reward = " << log::XMRAmount(final_reward) << ", transactions = " << m_numTransactionHashes << ", final_weight = " << final_weight);
|
||||||
|
|
||||||
uint64_t final_reward2;
|
uint64_t final_reward2;
|
||||||
fill_optimal_knapsack(data, base_reward, miner_tx_weight, final_reward2, final_fees, final_weight);
|
fill_optimal_knapsack(data, base_reward, miner_tx_weight, final_reward2, final_fees, final_weight);
|
||||||
LOGINFO(3, "best_reward = " << final_reward2 << ", transactions = " << m_numTransactionHashes << ", final_weight = " << final_weight);
|
LOGINFO(3, "best_reward = " << log::XMRAmount(final_reward2) << ", transactions = " << m_numTransactionHashes << ", final_weight = " << final_weight);
|
||||||
if (final_reward2 < final_reward) {
|
if (final_reward2 < final_reward) {
|
||||||
LOGERR(1, "fill_optimal_knapsack has a bug, found solution is not optimal. Fix it!");
|
LOGERR(1, "fill_optimal_knapsack has a bug, found solution is not optimal. Fix it!");
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
||||||
|
|
||||||
calc_merkle_tree_main_branch();
|
calc_merkle_tree_main_branch();
|
||||||
|
|
||||||
LOGINFO(3, "final reward = " << log::Gray() << final_reward << log::NoColor() <<
|
LOGINFO(3, "final reward = " << log::Gray() << log::XMRAmount(final_reward) << log::NoColor() <<
|
||||||
", weight = " << log::Gray() << final_weight << log::NoColor() <<
|
", weight = " << log::Gray() << final_weight << log::NoColor() <<
|
||||||
", outputs = " << log::Gray() << m_poolBlockTemplate->m_outputs.size() << log::NoColor() <<
|
", outputs = " << log::Gray() << m_poolBlockTemplate->m_outputs.size() << log::NoColor() <<
|
||||||
", " << log::Gray() << m_numTransactionHashes << log::NoColor() <<
|
", " << log::Gray() << m_numTransactionHashes << log::NoColor() <<
|
||||||
|
|
|
@ -254,10 +254,11 @@ struct MinerData
|
||||||
|
|
||||||
struct ChainMain
|
struct ChainMain
|
||||||
{
|
{
|
||||||
FORCEINLINE ChainMain() : height(0), timestamp(0), id() {}
|
FORCEINLINE ChainMain() : height(0), timestamp(0), reward(0), id() {}
|
||||||
|
|
||||||
uint64_t height;
|
uint64_t height;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
|
uint64_t reward;
|
||||||
hash id;
|
hash id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -178,8 +178,9 @@ void p2pool::handle_miner_data(MinerData& data)
|
||||||
c.height = data.height - 1;
|
c.height = data.height - 1;
|
||||||
c.id = data.prev_id;
|
c.id = data.prev_id;
|
||||||
|
|
||||||
// timestamp is unknown here
|
// timestamp and reward is unknown here
|
||||||
c.timestamp = 0;
|
c.timestamp = 0;
|
||||||
|
c.reward = 0;
|
||||||
|
|
||||||
m_mainchainByHash[c.id] = c;
|
m_mainchainByHash[c.id] = c;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +231,7 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
||||||
ChainMain& c = m_mainchainByHeight[data.height];
|
ChainMain& c = m_mainchainByHeight[data.height];
|
||||||
c.height = data.height;
|
c.height = data.height;
|
||||||
c.timestamp = data.timestamp;
|
c.timestamp = data.timestamp;
|
||||||
|
c.reward = data.reward;
|
||||||
|
|
||||||
// data.id not filled in here, but c.id should be available. Copy it to data.id for logging
|
// data.id not filled in here, but c.id should be available. Copy it to data.id for logging
|
||||||
data.id = c.id;
|
data.id = c.id;
|
||||||
|
@ -256,7 +258,8 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
||||||
|
|
||||||
LOGINFO(2, "new main chain block: height = " << log::Gray() << data.height << log::NoColor() <<
|
LOGINFO(2, "new main chain block: height = " << log::Gray() << data.height << log::NoColor() <<
|
||||||
", id = " << log::LightBlue() << data.id << log::NoColor() <<
|
", id = " << log::LightBlue() << data.id << log::NoColor() <<
|
||||||
", timestamp = " << log::Gray() << data.timestamp);
|
", timestamp = " << log::Gray() << data.timestamp << log::NoColor() <<
|
||||||
|
", reward = " << log::Gray() << log::XMRAmount(data.reward));
|
||||||
|
|
||||||
if (!sidechain_id.empty() && side_chain().has_block(sidechain_id)) {
|
if (!sidechain_id.empty() && side_chain().has_block(sidechain_id)) {
|
||||||
LOGINFO(0, log::LightGreen() << "BLOCK FOUND: main chain block at height " << data.height << " was mined by this p2pool" << BLOCK_FOUND);
|
LOGINFO(0, log::LightGreen() << "BLOCK FOUND: main chain block at height " << data.height << " was mined by this p2pool" << BLOCK_FOUND);
|
||||||
|
|
|
@ -219,42 +219,61 @@ void ZMQReader::parse(char* data, size_t size)
|
||||||
auto arr = doc.GetArray();
|
auto arr = doc.GetArray();
|
||||||
for (Value* i = arr.begin(); i != arr.end(); ++i) {
|
for (Value* i = arr.begin(); i != arr.end(); ++i) {
|
||||||
if (!PARSE(*i, m_chainmainData, timestamp)) {
|
if (!PARSE(*i, m_chainmainData, timestamp)) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main timestamp failed to parse, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = i->FindMember("miner_tx");
|
auto it = i->FindMember("miner_tx");
|
||||||
if ((it == i->MemberEnd()) || !it->value.IsObject()) {
|
if ((it == i->MemberEnd()) || !it->value.IsObject()) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main miner_tx not found, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto extra_it = it->value.FindMember("extra");
|
auto extra_it = it->value.FindMember("extra");
|
||||||
if ((extra_it == it->value.MemberEnd()) || !extra_it->value.IsString()) {
|
if ((extra_it == it->value.MemberEnd()) || !extra_it->value.IsString()) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main extra not found, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto inputs_it = it->value.FindMember("inputs");
|
auto inputs_it = it->value.FindMember("inputs");
|
||||||
if ((inputs_it == it->value.MemberEnd()) || !inputs_it->value.IsArray()) {
|
if ((inputs_it == it->value.MemberEnd()) || !inputs_it->value.IsArray()) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main inputs not found, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get block reward from miner_tx outputs
|
||||||
|
m_chainmainData.reward = 0;
|
||||||
|
|
||||||
|
auto outputs_it = it->value.FindMember("outputs");
|
||||||
|
if ((outputs_it != it->value.MemberEnd()) && outputs_it->value.IsArray()) {
|
||||||
|
auto outputs = outputs_it->value.GetArray();
|
||||||
|
for (SizeType j = 0, n = outputs.Size(); j < n; ++j) {
|
||||||
|
if (outputs[j].IsObject()) {
|
||||||
|
auto amount_it = outputs[j].FindMember("amount");
|
||||||
|
if (amount_it != outputs[j].MemberEnd() && amount_it->value.IsUint64()) {
|
||||||
|
m_chainmainData.reward += amount_it->value.GetUint64();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOGWARN(4, "json-full-chain_main outputs not found");
|
||||||
|
}
|
||||||
|
|
||||||
auto inputs = inputs_it->value.GetArray();
|
auto inputs = inputs_it->value.GetArray();
|
||||||
if ((inputs.Size() == 0) || !inputs[0].IsObject()) {
|
if ((inputs.Size() == 0) || !inputs[0].IsObject()) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main inputs is not an array, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
it = inputs[0].FindMember("gen");
|
it = inputs[0].FindMember("gen");
|
||||||
if ((it == inputs[0].MemberEnd()) || !it->value.IsObject()) {
|
if ((it == inputs[0].MemberEnd()) || !it->value.IsObject()) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main gen not found, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PARSE(it->value, m_chainmainData, height)) {
|
if (!PARSE(it->value, m_chainmainData, height)) {
|
||||||
LOGWARN(1, "json-full-chain_main array element failed to parse, skipping it");
|
LOGWARN(1, "json-full-chain_main height not found, skipping it");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue