Check network type at startup

- Make network type part of consensus ID to avoid mixing p2pool nodes from mainnet and testnet/stagenet
- Check that wallet address matches the network type of monerod
This commit is contained in:
SChernykh
2021-08-27 11:25:25 +02:00
parent afca83d6c2
commit 27c2aab145
9 changed files with 110 additions and 30 deletions
+11 -7
View File
@@ -51,8 +51,9 @@ static_assert(1 <= UNCLE_BLOCK_DEPTH && UNCLE_BLOCK_DEPTH <= 10, "Invalid UNCLE_
namespace p2pool {
SideChain::SideChain(p2pool* pool)
SideChain::SideChain(p2pool* pool, NetworkType type)
: m_pool(pool)
, m_networkType(type)
, m_chainTip(nullptr)
, m_poolName("default")
, m_targetBlockTime(1)
@@ -61,6 +62,8 @@ SideChain::SideChain(p2pool* pool)
, m_unclePenalty(20)
, m_curDifficulty(m_minDifficulty)
{
LOGINFO(1, log::LightCyan() << "network type = " << m_networkType);
if (!load_config(m_pool->params().m_config)) {
panic();
}
@@ -90,12 +93,13 @@ SideChain::SideChain(p2pool* pool)
char consensus_str[log::Stream::BUF_SIZE + 1];
log::Stream s(consensus_str);
s << m_poolName << '\0'
<< m_poolPassword << '\0'
<< m_targetBlockTime << '\0'
<< m_minDifficulty << '\0'
<< m_chainWindowSize << '\0'
<< m_unclePenalty << '\0';
s << m_networkType << '\0'
<< m_poolName << '\0'
<< m_poolPassword << '\0'
<< m_targetBlockTime << '\0'
<< m_minDifficulty << '\0'
<< m_chainWindowSize << '\0'
<< m_unclePenalty << '\0';
randomx_init_cache(cache, consensus_str, s.m_pos);
}