diff --git a/src/p2pool.cpp b/src/p2pool.cpp index aa26af4..2800dc9 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -588,7 +588,7 @@ void p2pool::submit_block_async(std::vector&& blob) } } -void p2pool::submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) +void p2pool::submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) const { size_t nonce_offset = 0; size_t extra_nonce_offset = 0; diff --git a/src/p2pool.h b/src/p2pool.h index 0d18624..09abffb 100644 --- a/src/p2pool.h +++ b/src/p2pool.h @@ -87,7 +87,7 @@ public: void submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce); void submit_block_async(std::vector&& blob); - void submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce); + void submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) const; bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce); diff --git a/tests/src/merkle_tests.cpp b/tests/src/merkle_tests.cpp index 420325c..2fe3915 100644 --- a/tests/src/merkle_tests.cpp +++ b/tests/src/merkle_tests.cpp @@ -281,12 +281,28 @@ TEST(merkle, params) ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0), 0x3F6U); ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0xFFFFFFFFU), 0x3FFFFFFFFF6ULL); + PoolBlock b; + uint32_t n1, nonce1; + + b.m_merkleTreeData = 0; + b.decode_merkle_tree_data(n1, nonce1); + ASSERT_TRUE(n1 == 1 && nonce1 == 0); + + b.m_merkleTreeData = 0xFFFFFFFF0ULL; + b.decode_merkle_tree_data(n1, nonce1); + ASSERT_TRUE(n1 == 1 && nonce1 == 0xFFFFFFFFU); + + b.m_merkleTreeData = 0x3F6U; + b.decode_merkle_tree_data(n1, nonce1); + ASSERT_TRUE(n1 == 127 && nonce1 == 0); + + b.m_merkleTreeData = 0x3FFFFFFFFF6ULL; + b.decode_merkle_tree_data(n1, nonce1); + ASSERT_TRUE(n1 == 127 && nonce1 == 0xFFFFFFFFU); + for (uint32_t n_aux_chains = 1; n_aux_chains < 128; ++n_aux_chains) { for (uint32_t nonce = 1; nonce; nonce <<= 1) { - PoolBlock b; b.m_merkleTreeData = PoolBlock::encode_merkle_tree_data(n_aux_chains, nonce); - - uint32_t n1, nonce1; b.decode_merkle_tree_data(n1, nonce1); ASSERT_EQ(n1, n_aux_chains); ASSERT_EQ(nonce1, nonce);