aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/difficulty.h
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-03-31 12:01:19 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-03-31 12:01:19 +0300
commitdf6026182ab1df95a07d01ad54481e7ebf2c69e7 (patch)
tree5b9813551c37b8ad30687e5c2aaae238d2119d5e /src/cryptonote_core/difficulty.h
parent- testnet option added to api; (diff)
parentMerge pull request #770 (diff)
downloadmonero-df6026182ab1df95a07d01ad54481e7ebf2c69e7.tar.xz
Merge remote-tracking branch 'upstream/master'
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);
}