Force update block template after 30 seconds

To get new transactions in
This commit is contained in:
SChernykh
2022-11-04 07:47:07 +01:00
parent 83cda110aa
commit 74b5ab1798
4 changed files with 21 additions and 0 deletions
+15
View File
@@ -25,6 +25,7 @@
#include "block_cache.h"
#include "json_rpc_request.h"
#include "json_parsers.h"
#include "block_template.h"
#include <rapidjson/document.h>
#include <fstream>
#include <numeric>
@@ -972,6 +973,7 @@ void P2PServer::on_timer()
save_peer_list_async();
update_peer_connections();
check_zmq();
check_block_template();
}
void P2PServer::flush_cache()
@@ -1106,6 +1108,19 @@ void P2PServer::check_zmq()
}
}
void P2PServer::check_block_template()
{
if (!m_pool->side_chain().precalcFinished()) {
return;
}
// Force update block template every 30 seconds after the initial sync is done
if (seconds_since_epoch() >= m_pool->block_template().last_updated() + 30) {
LOGINFO(4, "block template is 30 seconds old, updating it");
m_pool->update_block_template_async();
}
}
P2PServer::P2PClient::P2PClient()
: m_peerId(0)
, m_expectedMessage(MessageId::HANDSHAKE_CHALLENGE)