This commit is contained in:
SChernykh 2021-11-02 16:48:46 +01:00
parent 64116643c2
commit bb7a5b4d6d
4 changed files with 5 additions and 10 deletions

View file

@ -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);
@ -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;
@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);