Skip to content

Commit

Permalink
Simplify dynamic section of algorithm
Browse files Browse the repository at this point in the history
- Should result in a slight speedup for mining/verification
  • Loading branch information
who-biz committed Jun 22, 2020
1 parent 4a928c4 commit 6b64964
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/cryptonote_basic/cryptonote_format_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,17 +944,13 @@ namespace cryptonote
}
else if (b.major_version >= 10)
{
// get 6 char from previous hash as varint
epee::span<const uint8_t> span_bytes = epee::as_byte_span(b.prev_id);

uint8_t i = 0;
subhash sub; sub.uint = 0;
uint32_t id_num = 0;
for (const auto& byte : span_bytes) {
memcpy(&sub.bytes[i++], &byte, sizeof(byte));
id_num |= byte << (24 - (8*i));
if (i == 3)
break;
uint8_t bytes_span[3] = { 0, 0, 0 };

// get 6 char from previous hash as varint
for (size_t i = 0; i < 3; i++) {
memcpy(&bytes_span[i], &b.prev_id.data[i], sizeof(b.prev_id.data[i]));

This comment has been minimized.

Copy link
@cogitocat

cogitocat Jun 24, 2020

Could std::async be used here to parallelize iterations?

This comment has been minimized.

Copy link
@who-biz

who-biz Jun 24, 2020

Author Contributor

@cogitocat threading/async for the miner is written into: src/cryptonote_basic/miner.cpp

If you meant something other than that, feel free to explain. Note that get_block_longhash() is called in that function.

id_num |= bytes_span[i] << (24 - (8*(i+1)));
}

// guard against zero case
Expand Down

0 comments on commit 6b64964

Please sign in to comment.