mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Store only fully verified blocks in the cache
This commit is contained in:
parent
4837b4c863
commit
69533fd209
2 changed files with 7 additions and 3 deletions
|
@ -120,7 +120,7 @@ void P2PServer::add_cached_block(const PoolBlock& block)
|
||||||
|
|
||||||
void P2PServer::store_in_cache(const PoolBlock& block)
|
void P2PServer::store_in_cache(const PoolBlock& block)
|
||||||
{
|
{
|
||||||
if (m_cache) {
|
if (m_cache && block.m_verified && !block.m_invalid) {
|
||||||
m_cache->store(block);
|
m_cache->store(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1323,8 +1323,6 @@ bool P2PServer::P2PClient::handle_incoming_block_async(PoolBlock* block)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->store_in_cache(*block);
|
|
||||||
|
|
||||||
struct Work
|
struct Work
|
||||||
{
|
{
|
||||||
uv_work_t req;
|
uv_work_t req;
|
||||||
|
|
|
@ -441,6 +441,9 @@ void SideChain::add_block(const PoolBlock& block)
|
||||||
", verified = " << (block.m_verified ? 1 : 0)
|
", verified = " << (block.m_verified ? 1 : 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Save it for faster syncing on the next p2pool start
|
||||||
|
m_pool->p2p_server()->store_in_cache(block);
|
||||||
|
|
||||||
PoolBlock* new_block = new PoolBlock(block);
|
PoolBlock* new_block = new PoolBlock(block);
|
||||||
|
|
||||||
MutexLock lock(m_sidechainLock);
|
MutexLock lock(m_sidechainLock);
|
||||||
|
@ -816,6 +819,9 @@ void SideChain::verify_loop(PoolBlock* block)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save it for faster syncing on the next p2pool start
|
||||||
|
m_pool->p2p_server()->store_in_cache(*block);
|
||||||
|
|
||||||
// Try to verify blocks on top of this one
|
// Try to verify blocks on top of this one
|
||||||
for (size_t i = 1; i <= UNCLE_BLOCK_DEPTH; ++i) {
|
for (size_t i = 1; i <= UNCLE_BLOCK_DEPTH; ++i) {
|
||||||
auto it = m_blocksByHeight.find(block->m_sidechainHeight + i);
|
auto it = m_blocksByHeight.find(block->m_sidechainHeight + i);
|
||||||
|
|
Loading…
Reference in a new issue