mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-31 15:59:27 +00:00
SideChain: log blocks with the same id
This commit is contained in:
parent
cc92ae7998
commit
255d312ae0
4 changed files with 31 additions and 11 deletions
|
@ -2063,7 +2063,7 @@ bool P2PServer::P2PClient::handle_incoming_block_async(const PoolBlock* block)
|
|||
P2PServer* server = static_cast<P2PServer*>(m_owner);
|
||||
|
||||
if (server->m_pool->side_chain().block_seen(*block)) {
|
||||
LOGINFO(6, "block " << block->m_sidechainId << " was received before, skipping it");
|
||||
LOGINFO(6, "block " << block->m_sidechainId << " (nonce " << block->m_nonce << ", extra_nonce " << block->m_extraNonce << ") was received before, skipping it");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,18 @@ struct PoolBlock
|
|||
// Both tx types are allowed by Monero consensus during v15 because it needs to process pre-fork mempool transactions,
|
||||
// but P2Pool can switch to using only TXOUT_TO_TAGGED_KEY for miner payouts starting from v15
|
||||
FORCEINLINE uint8_t get_tx_type() const { return (m_majorVersion < HARDFORK_VIEW_TAGS_VERSION) ? TXOUT_TO_KEY : TXOUT_TO_TAGGED_KEY; }
|
||||
|
||||
typedef std::array<uint8_t, HASH_SIZE + NONCE_SIZE + EXTRA_NONCE_SIZE> full_id;
|
||||
|
||||
FORCEINLINE full_id get_full_id() const
|
||||
{
|
||||
full_id key;
|
||||
uint8_t* p = key.data();
|
||||
memcpy(p, m_sidechainId.h, HASH_SIZE);
|
||||
memcpy(p + HASH_SIZE, &m_nonce, NONCE_SIZE);
|
||||
memcpy(p + HASH_SIZE + NONCE_SIZE, &m_extraNonce, EXTRA_NONCE_SIZE);
|
||||
return key;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
|
|
@ -453,13 +453,13 @@ bool SideChain::block_seen(const PoolBlock& block)
|
|||
|
||||
// Check if it was received before
|
||||
MutexLock lock(m_seenBlocksLock);
|
||||
return !m_seenBlocks.insert(block.m_sidechainId).second;
|
||||
return !m_seenBlocks.insert(block.get_full_id()).second;
|
||||
}
|
||||
|
||||
void SideChain::unsee_block(const PoolBlock& block)
|
||||
{
|
||||
MutexLock lock(m_seenBlocksLock);
|
||||
m_seenBlocks.erase(block.m_sidechainId);
|
||||
m_seenBlocks.erase(block.get_full_id());
|
||||
}
|
||||
|
||||
bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks)
|
||||
|
@ -604,10 +604,20 @@ void SideChain::add_block(const PoolBlock& block)
|
|||
|
||||
auto result = m_blocksById.insert({ new_block->m_sidechainId, new_block });
|
||||
if (!result.second) {
|
||||
LOGWARN(3, "add_block: trying to add the same block twice, id = "
|
||||
<< new_block->m_sidechainId << ", sidechain height = "
|
||||
<< new_block->m_sidechainHeight << ", height = "
|
||||
<< new_block->m_txinGenHeight);
|
||||
const PoolBlock* old_block = result.first->second;
|
||||
|
||||
LOGWARN(3, "add_block: trying to add the same block twice:"
|
||||
<< "\nnew block id = " << new_block->m_sidechainId
|
||||
<< ", sidechain height = " << new_block->m_sidechainHeight
|
||||
<< ", height = " << new_block->m_txinGenHeight
|
||||
<< ", nonce = " << new_block->m_nonce
|
||||
<< ", extra_nonce = " << new_block->m_extraNonce
|
||||
<< "\nold block id = " << old_block->m_sidechainId
|
||||
<< ", sidechain height = " << old_block->m_sidechainHeight
|
||||
<< ", height = " << old_block->m_txinGenHeight
|
||||
<< ", nonce = " << old_block->m_nonce
|
||||
<< ", extra_nonce = " << old_block->m_extraNonce
|
||||
);
|
||||
|
||||
delete new_block;
|
||||
return;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "uv_util.h"
|
||||
#include "pool_block.h"
|
||||
#include <map>
|
||||
#include <thread>
|
||||
|
||||
|
@ -25,9 +26,6 @@ namespace p2pool {
|
|||
|
||||
class p2pool;
|
||||
class P2PServer;
|
||||
struct DifficultyData;
|
||||
struct PoolBlock;
|
||||
class Wallet;
|
||||
|
||||
struct MinerShare
|
||||
{
|
||||
|
@ -112,7 +110,7 @@ private:
|
|||
uint64_t m_seenWalletsLastPruneTime;
|
||||
|
||||
uv_mutex_t m_seenBlocksLock;
|
||||
unordered_set<hash> m_seenBlocks;
|
||||
unordered_set<PoolBlock::full_id> m_seenBlocks;
|
||||
|
||||
std::vector<DifficultyData> m_difficultyData;
|
||||
|
||||
|
|
Loading…
Reference in a new issue