Skip to content

Commit

Permalink
Don't update api when shutting down
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Sep 13, 2023
1 parent b83b691 commit 2248739
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Miner::on_block(const BlockTemplate& block)
m_nonceTimestamp = cur_ts;
m_totalHashes += hash_count;

if (m_pool->api() && m_pool->params().m_localStats) {
if (m_pool->api() && m_pool->params().m_localStats && !m_pool->stopped()) {
const double block_reward_share_percent = m_pool->side_chain().get_reward_share(m_pool->params().m_wallet) * 100.0;

m_pool->api()->set(p2pool_api::Category::LOCAL, "miner",
Expand Down
2 changes: 1 addition & 1 deletion src/p2p_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ void P2PServer::on_shutdown()

void P2PServer::api_update_local_stats()
{
if (!m_pool->api() || !m_pool->params().m_localStats || ((m_timerCounter % 30) != 5)) {
if (!m_pool->api() || !m_pool->params().m_localStats || m_pool->stopped() || ((m_timerCounter % 30) != 5)) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/p2pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ void p2pool::get_info()

void p2pool::load_found_blocks()
{
if (!m_api) {
if (!m_api || m_stopped) {
return;
}

Expand Down Expand Up @@ -1277,7 +1277,7 @@ uint32_t p2pool::parse_block_headers_range(const char* data, size_t size)

void p2pool::api_update_network_stats()
{
if (!m_api) {
if (!m_api || m_stopped) {
return;
}

Expand Down Expand Up @@ -1308,7 +1308,7 @@ void p2pool::api_update_network_stats()

void p2pool::api_update_pool_stats()
{
if (!m_api) {
if (!m_api || m_stopped) {
return;
}

Expand Down Expand Up @@ -1360,7 +1360,7 @@ void p2pool::api_update_pool_stats()

void p2pool::api_update_stats_mod()
{
if (!m_api) {
if (!m_api || m_stopped) {
return;
}

Expand Down Expand Up @@ -1453,7 +1453,7 @@ void p2pool::cleanup_mainchain_data(uint64_t height)

void p2pool::api_update_block_found(const ChainMain* data, const PoolBlock* block)
{
if (!m_api) {
if (!m_api || m_stopped) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ bool StratumServer::StratumClient::process_submit(rapidjson::Document& doc, uint

void StratumServer::api_update_local_stats(uint64_t timestamp)
{
if (!m_pool->api() || !m_pool->params().m_localStats) {
if (!m_pool->api() || !m_pool->params().m_localStats || m_pool->stopped()) {
return;
}

Expand Down

0 comments on commit 2248739

Please sign in to comment.