|
Electroneum
|
A container for blockchain checkpoints. More...
#include <checkpoints.h>
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 (network_type nettype) |
| loads the default main chain checkpoints More... | |
| bool | load_new_checkpoints (const std::string &json_hashfile_fullpath, network_type nettype=MAINNET, 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 (network_type nettype=MAINNET) |
| load new checkpoints from DNS 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.
Definition at line 51 of file checkpoints.h.
| cryptonote::checkpoints::checkpoints | ( | ) |
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 |
Definition at line 76 of file checkpoints.cpp.


| 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 |
Definition at line 96 of file checkpoints.cpp.

| 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.
Definition at line 114 of file checkpoints.cpp.
| 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 |
Definition at line 148 of file checkpoints.cpp.


| uint64_t cryptonote::checkpoints::get_max_height | ( | ) | const |
gets the highest checkpoint height
Definition at line 136 of file checkpoints.cpp.
| const std::map< uint64_t, crypto::hash > & cryptonote::checkpoints::get_points | ( | ) | const |
gets the checkpoints container
Definition at line 143 of file checkpoints.cpp.

| bool cryptonote::checkpoints::init_default_checkpoints | ( | network_type | nettype | ) |
loads the default main chain checkpoints
| nettype | network type |
Definition at line 160 of file checkpoints.cpp.

| 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 |
Definition at line 121 of file checkpoints.cpp.

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 |
Definition at line 91 of file checkpoints.cpp.
| bool cryptonote::checkpoints::load_checkpoints_from_dns | ( | network_type | nettype = MAINNET | ) |
load new checkpoints from DNS
| nettype | network type |
Definition at line 232 of file checkpoints.cpp.


| 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 |
Definition at line 196 of file checkpoints.cpp.


| bool cryptonote::checkpoints::load_new_checkpoints | ( | const std::string & | json_hashfile_fullpath, |
| network_type | nettype = MAINNET, |
||
| 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 |
| nettype | network type |
| dns | whether or not to load DNS checkpoints |
Definition at line 291 of file checkpoints.cpp.