aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/difficulty.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-03-25 08:22:06 +0200
committerRiccardo Spagni <ric@spagni.net>2016-03-25 09:12:25 +0200
commit0d30b657859d6ebd3188bd16dfaa9c79c3dfcaa7 (patch)
tree0e4c9a35e9bbfcffcca4631d944031d0fbc7efb4 /src/cryptonote_core/difficulty.h
parentMerge pull request #761 (diff)
downloadmonero-0d30b657859d6ebd3188bd16dfaa9c79c3dfcaa7.tar.xz
Merge pull request #749
bfd4a28 Update BlockchainDB documentation (Thomas Winget) 797357e Change Doxyfile, Blockchain not blockchain_storage (Thomas Winget) c835215 remove defunct code from cryptonote::core (Thomas Winget) 50dba6d cryptonote::core doxygen documentation (Thomas Winget) 8ac329d doxygen documentation for difficulty functions (Thomas Winget) 540a76c Move checkpoint functions into checkpoints class (Thomas Winget) 1b0c98e doxygen documentation for checkpoints.{h,cpp} (Thomas Winget) 89c24ac Remove unnecessary or defunct code (Thomas Winget) ab0ed14 doxygen include private and static members (Thomas Winget) 3a48449 Updated documentation for blockchain.* (Thomas Winget)
Diffstat (limited to 'src/cryptonote_core/difficulty.h')
-rw-r--r--src/cryptonote_core/difficulty.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cryptonote_core/difficulty.h b/src/cryptonote_core/difficulty.h
index d49c2f3b8..910f97035 100644
--- a/src/cryptonote_core/difficulty.h
+++ b/src/cryptonote_core/difficulty.h
@@ -39,6 +39,18 @@ namespace cryptonote
{
typedef std::uint64_t difficulty_type;
+ /**
+ * @brief checks if a hash fits the given difficulty
+ *
+ * The hash passes if (hash * difficulty) < 2^192.
+ * Phrased differently, if (hash * difficulty) fits without overflow into
+ * the least significant 192 bits of the 256 bit multiplication result.
+ *
+ * @param hash the hash to check
+ * @param difficulty the difficulty to check against
+ *
+ * @return true if valid, else false
+ */
bool check_hash(const crypto::hash &hash, difficulty_type difficulty);
difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
}