Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Nov 2, 2021
1 parent 6411664 commit bb7a5b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
12 changes: 5 additions & 7 deletions src/pool_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ PoolBlock::PoolBlock()
m_mainChainData.reserve(48 * 1024);
m_outputs.reserve(2048);
m_transactions.reserve(256);
m_tmpInts.reserve(m_transactions.capacity() * HASH_SIZE);
m_sideChainData.reserve(512);
m_uncles.reserve(8);
m_tmpTxExtra.reserve(80);
Expand Down Expand Up @@ -110,7 +109,6 @@ PoolBlock& PoolBlock::operator=(const PoolBlock& b)
m_cumulativeDifficulty = b.m_cumulativeDifficulty;
m_sidechainId = b.m_sidechainId;
m_tmpTxExtra = b.m_tmpTxExtra;
m_tmpInts = b.m_tmpInts;
m_depth = b.m_depth;
m_verified = b.m_verified;
m_invalid = b.m_invalid;
Expand Down Expand Up @@ -276,21 +274,21 @@ bool PoolBlock::get_pow_hash(RandomX_Hasher* hasher, const hash& seed_hash, hash

cnt >>= 1;

m_tmpInts.resize(cnt * HASH_SIZE);
memcpy(m_tmpInts.data(), h, (cnt * 2 - count) * HASH_SIZE);
std::vector<uint8_t> tmp_ints(cnt * HASH_SIZE);
memcpy(tmp_ints.data(), h, (cnt * 2 - count) * HASH_SIZE);

for (i = cnt * 2 - count, j = cnt * 2 - count; j < cnt; i += 2, ++j) {
keccak(h + i * HASH_SIZE, HASH_SIZE * 2, m_tmpInts.data() + j * HASH_SIZE, HASH_SIZE);
keccak(h + i * HASH_SIZE, HASH_SIZE * 2, tmp_ints.data() + j * HASH_SIZE, HASH_SIZE);
}

while (cnt > 2) {
cnt >>= 1;
for (i = 0, j = 0; j < cnt; i += 2, ++j) {
keccak(m_tmpInts.data() + i * HASH_SIZE, HASH_SIZE * 2, m_tmpInts.data() + j * HASH_SIZE, HASH_SIZE);
keccak(tmp_ints.data() + i * HASH_SIZE, HASH_SIZE * 2, tmp_ints.data() + j * HASH_SIZE, HASH_SIZE);
}
}

keccak(m_tmpInts.data(), HASH_SIZE * 2, blob + blob_size, HASH_SIZE);
keccak(tmp_ints.data(), HASH_SIZE * 2, blob + blob_size, HASH_SIZE);
}
}
blob_size += HASH_SIZE;
Expand Down
1 change: 0 additions & 1 deletion src/pool_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ struct PoolBlock

// Just temporary stuff, not a part of the block
std::vector<uint8_t> m_tmpTxExtra;
std::vector<uint8_t> m_tmpInts;

uint64_t m_depth;

Expand Down
1 change: 0 additions & 1 deletion src/pool_block_parser.inl
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, SideChain& sidechai

// Defaults for off-chain variables
m_tmpTxExtra.clear();
m_tmpInts.clear();

m_depth = 0;

Expand Down
1 change: 0 additions & 1 deletion tests/src/pool_block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ TEST(pool_block, deserialize)
ASSERT_EQ(b.m_cumulativeDifficulty.lo, 12544665764606ull);
ASSERT_EQ(b.m_cumulativeDifficulty.hi, 0);
ASSERT_EQ(b.m_tmpTxExtra.size(), 0);
ASSERT_EQ(b.m_tmpInts.size(), 0);
ASSERT_EQ(b.m_depth, 0);
ASSERT_EQ(b.m_verified, false);
ASSERT_EQ(b.m_invalid, false);
Expand Down

0 comments on commit bb7a5b4

Please sign in to comment.