Fix: api didn't always save total hashes
This commit is contained in:
@@ -409,7 +409,7 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
||||
if (payout) {
|
||||
LOGINFO(0, log::LightCyan() << "You received a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
|
||||
}
|
||||
api_update_block_found(&data);
|
||||
api_update_block_found(&data, block);
|
||||
}
|
||||
else {
|
||||
side_chain().watch_mainchain_block(data, sidechain_id);
|
||||
@@ -855,7 +855,7 @@ void p2pool::load_found_blocks()
|
||||
m_foundBlocks.emplace_back(timestamp, height, id, block_difficulty, cumulative_difficulty);
|
||||
}
|
||||
|
||||
api_update_block_found(nullptr);
|
||||
api_update_block_found(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void p2pool::parse_get_info_rpc(const char* data, size_t size)
|
||||
@@ -1325,14 +1325,14 @@ void p2pool::cleanup_mainchain_data(uint64_t height)
|
||||
}
|
||||
}
|
||||
|
||||
void p2pool::api_update_block_found(const ChainMain* data)
|
||||
void p2pool::api_update_block_found(const ChainMain* data, const PoolBlock* block)
|
||||
{
|
||||
if (!m_api) {
|
||||
return;
|
||||
}
|
||||
|
||||
const time_t cur_time = time(nullptr);
|
||||
const difficulty_type total_hashes = m_sideChain->total_hashes();
|
||||
const difficulty_type total_hashes = block ? block->m_cumulativeDifficulty : m_sideChain->total_hashes();
|
||||
difficulty_type diff;
|
||||
|
||||
if (data && get_difficulty_at_height(data->height, diff)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ class Miner;
|
||||
class ConsoleCommands;
|
||||
class p2pool_api;
|
||||
class ZMQReader;
|
||||
struct PoolBlock;
|
||||
|
||||
class p2pool : public MinerCallbackHandler
|
||||
{
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
|
||||
bool chainmain_get_by_hash(const hash& id, ChainMain& data) const;
|
||||
|
||||
void api_update_block_found(const ChainMain* data);
|
||||
void api_update_block_found(const ChainMain* data, const PoolBlock* block);
|
||||
|
||||
bool get_difficulty_at_height(uint64_t height, difficulty_type& diff);
|
||||
|
||||
|
||||
@@ -578,7 +578,7 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
|
||||
}
|
||||
|
||||
if (block_found) {
|
||||
m_pool->api_update_block_found(&data);
|
||||
m_pool->api_update_block_found(&data, &block);
|
||||
}
|
||||
|
||||
add_block(block);
|
||||
|
||||
Reference in New Issue
Block a user