Skip to content

Commit

Permalink
Fixed cppcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Dec 24, 2024
1 parent 8cc4935 commit e95cc65
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/p2p_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1944,11 +1944,9 @@ void P2PServer::P2PClient::send_handshake_solution(const uint8_t (&challenge)[CH
}
}

bool P2PServer::P2PClient::check_handshake_solution(const hash& solution, const uint8_t (&solution_salt)[CHALLENGE_SIZE])
bool P2PServer::P2PClient::check_handshake_solution(const hash& solution, const uint8_t (&solution_salt)[CHALLENGE_SIZE]) const
{
P2PServer* owner = static_cast<P2PServer*>(m_owner);

const std::vector<uint8_t>& consensus_id = owner->m_pool->side_chain().consensus_id();
const std::vector<uint8_t>& consensus_id = static_cast<const P2PServer*>(m_owner)->m_pool->side_chain().consensus_id();
const int consensus_id_size = static_cast<int>(consensus_id.size());

uint8_t challenge[CHALLENGE_SIZE];
Expand Down
4 changes: 2 additions & 2 deletions src/p2p_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class P2PServer : public TCPServer

[[nodiscard]] bool send_handshake_challenge();
void send_handshake_solution(const uint8_t (&challenge)[CHALLENGE_SIZE]);
[[nodiscard]] bool check_handshake_solution(const hash& solution, const uint8_t (&solution_salt)[CHALLENGE_SIZE]);
[[nodiscard]] bool check_handshake_solution(const hash& solution, const uint8_t (&solution_salt)[CHALLENGE_SIZE]) const;

[[nodiscard]] bool on_handshake_challenge(const uint8_t* buf);
[[nodiscard]] bool on_handshake_solution(const uint8_t* buf);
Expand All @@ -115,7 +115,7 @@ class P2PServer : public TCPServer
void on_block_notify(const uint8_t* buf);

[[nodiscard]] bool handle_incoming_block_async(const PoolBlock* block, uint64_t max_time_delta = 0);
void handle_incoming_block(p2pool* pool, PoolBlock& block, std::vector<hash>& missing_blocks, bool& result);
static void handle_incoming_block(p2pool* pool, PoolBlock& block, std::vector<hash>& missing_blocks, bool& result);
void post_handle_incoming_block(p2pool* pool, const PoolBlock& block, const uint32_t reset_counter, bool is_v6, const raw_ip& addr, std::vector<hash>& missing_blocks, const bool result);

[[nodiscard]] bool is_good() const { return m_handshakeComplete && !m_handshakeInvalid && (m_listenPort >= 0); }
Expand Down
8 changes: 4 additions & 4 deletions src/p2pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,12 @@ void p2pool::update_aux_data(const hash& chain_id)

aux_id.reserve(m_mergeMiningClients.size() + 1);

IMergeMiningClient::ChainParameters params;
IMergeMiningClient::ChainParameters chain_params;

for (const IMergeMiningClient* c : m_mergeMiningClients) {
if (c->get_params(params)) {
data.aux_chains.emplace_back(params.aux_id, params.aux_hash, params.aux_diff);
aux_id.emplace_back(params.aux_id);
if (c->get_params(chain_params)) {
data.aux_chains.emplace_back(chain_params.aux_id, chain_params.aux_hash, chain_params.aux_diff);
aux_id.emplace_back(chain_params.aux_id);
}
}
aux_id.emplace_back(m_sideChain->consensus_hash());
Expand Down
1 change: 0 additions & 1 deletion src/side_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ void SideChain::cleanup_incoming_blocks()
MutexLock lock(m_incomingBlocksLock);

// Forget seen blocks that were added more than 10 minutes ago
hash h;
for (auto i = m_incomingBlocks.begin(); i != m_incomingBlocks.end();) {
if (cur_time < i->second + 10 * 60) {
++i;
Expand Down

0 comments on commit e95cc65

Please sign in to comment.