Add CAP exchange protocol, Deadlock fix, Sync stuck fix with retry mechanism
This commit is contained in:
+20
-16
@@ -191,7 +191,7 @@ void BlockCache::store(const PoolBlock& block)
|
||||
memcpy(data + sizeof(uint32_t) + n1, sidechain_data.data(), n2);
|
||||
}
|
||||
|
||||
void BlockCache::load_all(const SideChain& side_chain, P2PServer& server)
|
||||
void BlockCache::load_all(SideChain& side_chain, P2PServer& server)
|
||||
{
|
||||
// Check cache version - invalidates on recompile
|
||||
const std::string version_path = DATA_DIR + "p2pool.cache.version";
|
||||
@@ -221,26 +221,30 @@ void BlockCache::load_all(const SideChain& side_chain, P2PServer& server)
|
||||
return;
|
||||
}
|
||||
|
||||
LOGINFO(1, "loading cached blocks");
|
||||
LOGINFO(1, "Loading cached blocks...");
|
||||
|
||||
PoolBlock block;
|
||||
uint32_t blocks_loaded = 0;
|
||||
PoolBlock block;
|
||||
uint32_t blocks_loaded = 0;
|
||||
|
||||
for (uint64_t i = 0; i < NUM_BLOCKS; ++i) {
|
||||
const uint8_t* data = m_impl->m_data + i * BLOCK_SIZE;
|
||||
const uint32_t n = *reinterpret_cast<const uint32_t*>(data);
|
||||
for (uint64_t i = 0; i < NUM_BLOCKS; ++i) {
|
||||
const uint8_t* data = m_impl->m_data + i * BLOCK_SIZE;
|
||||
const uint32_t n = *reinterpret_cast<const uint32_t*>(data);
|
||||
|
||||
if (!n || (n + sizeof(uint32_t) > BLOCK_SIZE)) {
|
||||
continue;
|
||||
}
|
||||
if (!n || (n + sizeof(uint32_t) > BLOCK_SIZE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.deserialize(data + sizeof(uint32_t), n, side_chain, uv_default_loop_checked(), false) == 0) {
|
||||
server.add_cached_block(block);
|
||||
++blocks_loaded;
|
||||
}
|
||||
}
|
||||
if (block.deserialize(data + sizeof(uint32_t), n, side_chain, uv_default_loop_checked(), false) == 0) {
|
||||
server.add_cached_block(block);
|
||||
++blocks_loaded;
|
||||
}
|
||||
}
|
||||
|
||||
LOGINFO(1, "loaded " << blocks_loaded << " cached blocks");
|
||||
if (blocks_loaded > 0) {
|
||||
LOGINFO(1, "Loaded " << blocks_loaded << " blocks from cache");
|
||||
} else {
|
||||
LOGINFO(1, "Cache empty, will sync from peers");
|
||||
}
|
||||
}
|
||||
|
||||
void BlockCache::flush()
|
||||
|
||||
Reference in New Issue
Block a user