mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-03 09:19:24 +00:00
Fixed block broadcasts
This commit is contained in:
parent
df2a81d76d
commit
f7a2a6fe07
3 changed files with 40 additions and 3 deletions
|
@ -110,7 +110,7 @@ class Worker
|
|||
public:
|
||||
enum params : int
|
||||
{
|
||||
SLOT_SIZE = 1024,
|
||||
SLOT_SIZE = log::Stream::BUF_SIZE + 1,
|
||||
BUF_SIZE = SLOT_SIZE * 8192,
|
||||
};
|
||||
|
||||
|
|
|
@ -810,6 +810,7 @@ void P2PServer::broadcast(const PoolBlock& block, const PoolBlock* parent)
|
|||
|
||||
writeVarint(total_reward, data->pruned_blob);
|
||||
writeVarint(outputs_blob_size, data->pruned_blob);
|
||||
data->pruned_blob.insert(data->pruned_blob.end(), block.m_sidechainId.h, block.m_sidechainId.h + HASH_SIZE);
|
||||
|
||||
data->pruned_blob.insert(data->pruned_blob.end(), mainchain_data.begin() + outputs_offset + outputs_blob_size, mainchain_data.end());
|
||||
|
||||
|
@ -890,6 +891,32 @@ void P2PServer::on_broadcast()
|
|||
return;
|
||||
}
|
||||
|
||||
if (pool_block_debug()) {
|
||||
for (Broadcast* data : broadcast_queue) {
|
||||
if (!data->compact_blob.empty()) {
|
||||
PoolBlock check;
|
||||
const int result = check.deserialize(data->compact_blob.data(), data->compact_blob.size(), m_pool->side_chain(), nullptr, true);
|
||||
if (result != 0) {
|
||||
LOGERR(1, "compact blob broadcast is broken, error " << result);
|
||||
}
|
||||
}
|
||||
{
|
||||
PoolBlock check;
|
||||
const int result = check.deserialize(data->pruned_blob.data(), data->pruned_blob.size(), m_pool->side_chain(), nullptr, false);
|
||||
if (result != 0) {
|
||||
LOGERR(1, "pruned blob broadcast is broken, error " << result);
|
||||
}
|
||||
}
|
||||
{
|
||||
PoolBlock check;
|
||||
const int result = check.deserialize(data->blob.data(), data->blob.size(), m_pool->side_chain(), nullptr, false);
|
||||
if (result != 0) {
|
||||
LOGERR(1, "full blob broadcast is broken, error " << result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (P2PClient* client = static_cast<P2PClient*>(m_connectedClientsList->m_next); client != m_connectedClientsList; client = static_cast<P2PClient*>(client->m_next)) {
|
||||
if (!client->is_good()) {
|
||||
continue;
|
||||
|
|
|
@ -129,6 +129,8 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
|||
|
||||
outputs_blob_size = static_cast<int>(data - data_begin) - outputs_offset;
|
||||
outputs_blob.assign(data_begin + outputs_offset, data);
|
||||
|
||||
m_sidechainId.clear();
|
||||
}
|
||||
else {
|
||||
// Outputs are not in the buffer and must be calculated from sidechain data
|
||||
|
@ -144,6 +146,9 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
|||
}
|
||||
|
||||
outputs_blob_size = static_cast<int>(tmp);
|
||||
|
||||
// Required by sidechain.get_outputs_blob() to speed up repeated broadcasts from different peers
|
||||
READ_BUF(m_sidechainId.h, HASH_SIZE);
|
||||
}
|
||||
|
||||
// Technically some p2pool node could keep stuffing block with transactions until reward is less than 0.6 XMR
|
||||
|
@ -415,6 +420,13 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
|||
},
|
||||
static_cast<int>(size + outputs_blob_size_diff + transactions_blob_size_diff + consensus_id.size()), check.h, HASH_SIZE);
|
||||
|
||||
if (m_sidechainId.empty()) {
|
||||
m_sidechainId = check;
|
||||
}
|
||||
else if (m_sidechainId != check) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
#if POOL_BLOCK_DEBUG
|
||||
m_sideChainDataDebug.assign(sidechain_data_begin, data_end);
|
||||
#endif
|
||||
|
@ -424,8 +436,6 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
|||
if (!verify_merkle_proof(check, m_merkleProof, mm_aux_slot, mm_n_aux_chains, m_merkleRoot)) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
m_sidechainId = check;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
LOGERR(0, "Exception in PoolBlock::deserialize(): " << e.what());
|
||||
|
|
Loading…
Reference in a new issue