diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-08-02 15:48:39 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-09-15 11:40:28 +0000 |
commit | 4971219c2cd5eae7060f17be077b909b6bd4695b (patch) | |
tree | 79b159eb066d98222633e3845ee842b41dd794bc /src/cryptonote_core/blockchain.h | |
parent | Merge pull request #6815 (diff) | |
download | monero-4971219c2cd5eae7060f17be077b909b6bd4695b.tar.xz |
blockchain: deterministic UNIX time unlock checks
Based on a patch by TheCharlatan <seb.kung@gmail.com>
Diffstat (limited to 'src/cryptonote_core/blockchain.h')
-rw-r--r-- | src/cryptonote_core/blockchain.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 20bd3e5d3..a9b7ca1da 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -1042,6 +1042,21 @@ namespace cryptonote */ void flush_invalid_blocks(); + /** + * @brief get the "adjusted time" + * + * Computes the median timestamp of the previous 60 blocks, projects it + * onto the current block to get an 'adjusted median time' which approximates + * what the current block's timestamp should be. Also projects the previous + * block's timestamp to estimate the current block's timestamp. + * + * Returns the minimum of the two projections, or the current local time on + * the machine if less than 60 blocks are available. + * + * @return current time approximated from chain data + */ + uint64_t get_adjusted_time(uint64_t height) const; + #ifndef IN_UNIT_TESTS private: #endif @@ -1182,10 +1197,11 @@ namespace cryptonote * @param output_keys return-by-reference the public keys of the outputs in the input set * @param rct_signatures the ringCT signatures, which are only valid if tx version > 1 * @param pmax_related_block_height return-by-pointer the height of the most recent block in the input set + * @param hf_version the consensus rules version to use * * @return false if any output is not yet unlocked, or is missing, otherwise true */ - bool check_tx_input(size_t tx_version,const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const rct::rctSig &rct_signatures, std::vector<rct::ctkey> &output_keys, uint64_t* pmax_related_block_height) const; + bool check_tx_input(size_t tx_version,const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const rct::rctSig &rct_signatures, std::vector<rct::ctkey> &output_keys, uint64_t* pmax_related_block_height, uint8_t hf_version) const; /** * @brief validate a transaction's inputs and their keys @@ -1373,10 +1389,11 @@ namespace cryptonote * unlock_time is either a block index or a unix time. * * @param unlock_time the unlock parameter (height or time) + * @param hf_version the consensus rules version to use * * @return true if spendable, otherwise false */ - bool is_tx_spendtime_unlocked(uint64_t unlock_time) const; + bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint8_t hf_version) const; /** * @brief stores an invalid block in a separate container @@ -1438,16 +1455,6 @@ namespace cryptonote bool check_block_timestamp(std::vector<uint64_t>& timestamps, const block& b) const { uint64_t median_ts; return check_block_timestamp(timestamps, b, median_ts); } /** - * @brief get the "adjusted time" - * - * Currently this simply returns the current time according to the - * user's machine. - * - * @return the current time - */ - uint64_t get_adjusted_time() const; - - /** * @brief finish an alternate chain's timestamp window from the main chain * * for an alternate chain, get the timestamps from the main chain to complete |