Conversation
roundDownToPowerOfTwo_64 should not be passed a zero
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two undefined-behavior cases in configuration parsing and tests must be corrected.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Updates user-facing values and configuration to use BLAKE2b difficulty units while retaining internal p-difficulty accounting.
Changes:
- Adds difficulty conversion, formatting, and network calculation utilities.
- Supports SI-suffixed difficulty configuration and display.
- Caps vardiff growth and validates pool-provided minimums.
| File | Description |
|---|---|
src/datum_utils.h |
Declares difficulty types and helpers. |
src/datum_utils.c |
Implements calculation and SI formatting. |
src/datum_utils_tests.c |
Tests difficulty utilities. |
src/datum_stratum.c |
Caps vardiff growth safely. |
src/datum_protocol.c |
Normalizes and displays pool difficulty. |
src/datum_protocol_tests.c |
Tests pool difficulty boundaries. |
src/datum_conf.h |
Adds the difficulty configuration type. |
src/datum_conf.c |
Parses and emits difficulty values. |
src/datum_conf_tests.c |
Tests difficulty parsing. |
src/datum_api.c |
Displays converted difficulty values. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| static void datum_conf_test_difficulty_(json_t * const input, const int expected_ret, const int expected_pdiff, | ||
| const char * const expr, const unsigned int line, const char * const func) { | ||
| assert(input); | ||
| const char err[0x100]; |
| long double rounding_unit; | ||
| if (end[0]) { | ||
| static const char suffixes[] = "KMGTPEZYRQ"; | ||
| const char * const suffix = strchr(suffixes, toupper(end[0])); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.