|
Electroneum
|
A container for blockchain checkpoints. More...
#include <checkpoints.h>
Classes | |
| struct | t_hash_json |
| struct for loading many checkpoints from json More... | |
| struct | t_hashline |
| struct for loading a checkpoint from json More... | |
Public Member Functions | |
| checkpoints () | |
| default constructor More... | |
| bool | add_checkpoint (uint64_t height, const std::string &hash_str) |
| adds a checkpoint to the container More... | |
| bool | is_in_checkpoint_zone (uint64_t height) const |
| checks if there is a checkpoint in the future More... | |
| bool | check_block (uint64_t height, const crypto::hash &h, bool &is_a_checkpoint) const |
| checks if the given height and hash agree with the checkpoints More... | |
| bool | check_block (uint64_t height, const crypto::hash &h) const |
| bool | is_alternative_block_allowed (uint64_t blockchain_height, uint64_t block_height) const |
| checks if alternate chain blocks should be kept for a given height More... | |
| uint64_t | get_max_height () const |
| gets the highest checkpoint height More... | |
| const std::map< uint64_t, crypto::hash > & | get_points () const |
| gets the checkpoints container More... | |
| bool | check_for_conflicts (const checkpoints &other) const |
| checks if our checkpoints container conflicts with another More... | |
| bool | init_default_checkpoints () |
| loads the default main chain checkpoints More... | |
| bool | load_new_checkpoints (const std::string json_hashfile_fullpath, bool testnet=false, bool dns=true) |
| load new checkpoints More... | |
| bool | load_checkpoints_from_json (const std::string json_hashfile_fullpath) |
| load new checkpoints from json More... | |
| bool | load_checkpoints_from_dns (bool testnet=false) |
| load new checkpoints from DNS More... | |
Private Attributes | |
| std::map< uint64_t, crypto::hash > | m_points |
| the checkpoints container More... | |
A container for blockchain checkpoints.
A checkpoint is a pre-defined hash for the block at a given height. Some of these are compiled-in, while others can be loaded at runtime either from a json file or via DNS from a checkpoint-hosting server.
| cryptonote::checkpoints::checkpoints | ( | ) |
default constructor
| bool cryptonote::checkpoints::add_checkpoint | ( | uint64_t | height, |
| const std::string & | hash_str | ||
| ) |
adds a checkpoint to the container
| height | the height of the block the checkpoint is for |
| hash_str | the hash of the block, as a string |
| bool cryptonote::checkpoints::check_block | ( | uint64_t | height, |
| const crypto::hash & | h, | ||
| bool & | is_a_checkpoint | ||
| ) | const |
checks if the given height and hash agree with the checkpoints
This function checks if the given height and hash exist in the checkpoints container. If so, it returns whether or not the passed parameters match the stored values.
| height | the height to be checked |
| h | the hash to be checked |
| is_a_checkpoint | return-by-reference if there is a checkpoint at the given height |
| bool cryptonote::checkpoints::check_block | ( | uint64_t | height, |
| const crypto::hash & | h | ||
| ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| bool cryptonote::checkpoints::check_for_conflicts | ( | const checkpoints & | other | ) | const |
checks if our checkpoints container conflicts with another
A conflict refers to a case where both checkpoint sets have a checkpoint for a specific height but their hashes for that height do not match.
| other | the other checkpoints instance to check against |
| uint64_t cryptonote::checkpoints::get_max_height | ( | ) | const |
gets the highest checkpoint height
| const std::map< uint64_t, crypto::hash > & cryptonote::checkpoints::get_points | ( | ) | const |
gets the checkpoints container
| bool cryptonote::checkpoints::init_default_checkpoints | ( | ) |
loads the default main chain checkpoints
| bool cryptonote::checkpoints::is_alternative_block_allowed | ( | uint64_t | blockchain_height, |
| uint64_t | block_height | ||
| ) | const |
checks if alternate chain blocks should be kept for a given height
this basically says if the blockchain is smaller than the first checkpoint then alternate blocks are allowed. Alternatively, if the last checkpoint before the end of the current chain is also before the block to be added, then this is fine.
| blockchain_height | the current blockchain height |
| block_height | the height of the block to be added as alternate |
| bool cryptonote::checkpoints::is_in_checkpoint_zone | ( | uint64_t | height | ) | const |
checks if there is a checkpoint in the future
This function checks if the height passed is lower than the highest checkpoint.
| height | the height to check against |
load new checkpoints from DNS
| testnet | whether to load testnet checkpoints or mainnet |
| bool cryptonote::checkpoints::load_checkpoints_from_json | ( | const std::string | json_hashfile_fullpath | ) |
load new checkpoints from json
| json_hashfile_fullpath | path to the json checkpoints file |
| bool cryptonote::checkpoints::load_new_checkpoints | ( | const std::string | json_hashfile_fullpath, |
| bool | testnet = false, |
||
| bool | dns = true |
||
| ) |
load new checkpoints
Loads new checkpoints from the specified json file, as well as (optionally) from DNS.
| json_hashfile_fullpath | path to the json checkpoints file |
| testnet | whether to load testnet checkpoints or mainnet |
| dns | whether or not to load DNS checkpoints |
|
private |
the checkpoints container
1.8.14