Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mining: Improve template key handling. #1709

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Mar 30, 2019

This factors out the code which deals with generating a unique block template key to a separate function, modifies it to only be comprised of the merkle root + timestamp, and renames the associated variables
accordingly. The separate function is useful because work submission will ultimately need to create the same key.

The rationale for switching to only using the merkle root + timestamp is as follows:

  • It is more efficient to use smaller keys
  • The combination is guaranteed to be unique for every template so long as there are no more than one per second generated with the exact same transactions (which is already the case with the inclusion of the stake merkle root in the key too)
  • There are future plans to combine the stake root and merkle roots into the merkle root field and repurpose the stake root

Finally, the naming is also being changed from ID to key because the name templateID already has a distinct meaning in the rpcserver code in how it applies to long polling clients and it is better to avoid potential confusion.

@davecgh davecgh added this to the 1.5.0 milestone Mar 30, 2019
mining.go Outdated Show resolved Hide resolved
@davecgh davecgh force-pushed the mining_improve_template_key_handling branch 2 times, most recently from 6948b2b to 0323424 Compare March 30, 2019 23:33
This factors out the code which deals with generating a unique block
template key to a separate function, modifies it to only be comprised of
the merkle root + timestamp, and renames the associated variables
accordingly.  The separate function is useful because work submission
will ultimately need to create the same key.

The rationale for switching to only using the merkle root + timestamp is
as follows:

- It is more efficient to use smaller keys
- The combination is guaranteed to be unique for every template so long
  as there are no more than one per second generated with the exact same
  txns (which is already the case with the inclusion of the stake merkle
  root in the key too)
- There are future plans to combine the stake root and merkle roots into
  the merkle root field and repurpose the stake root

Finally, the naming is also being changed from ID to key because the
name templateID already has a distinct meaning in the rpcserver code in
how it applies to long polling clients and it is better to avoid
potential confusion.
@davecgh davecgh force-pushed the mining_improve_template_key_handling branch from 0323424 to 6875c3f Compare April 1, 2019 16:12
@davecgh davecgh merged commit 6875c3f into decred:master Apr 1, 2019
@davecgh davecgh deleted the mining_improve_template_key_handling branch April 1, 2019 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants