|
Electroneum
|
#include <hardfork.h>

Classes | |
| struct | Params |
Public Types | |
| enum | State { LikelyForked, UpdateNeeded, Ready } |
Public Member Functions | |
| HardFork (cryptonote::BlockchainDB &db, uint8_t original_version=1, uint64_t original_version_till_height=DEFAULT_ORIGINAL_VERSION_TILL_HEIGHT, time_t forked_time=DEFAULT_FORKED_TIME, time_t update_time=DEFAULT_UPDATE_TIME, uint64_t window_size=DEFAULT_WINDOW_SIZE, uint8_t default_threshold_percent=DEFAULT_THRESHOLD_PERCENT) | |
| creates a new HardFork object More... | |
| bool | add_fork (uint8_t version, uint64_t height, uint8_t threshold, time_t time) |
| add a new hardfork height More... | |
| bool | add_fork (uint8_t version, uint64_t height, time_t time) |
| add a new hardfork height More... | |
| void | init () |
| initialize the object More... | |
| bool | check (const cryptonote::block &block) const |
| check whether a new block would be accepted More... | |
| bool | check_for_height (const cryptonote::block &block, uint64_t height) const |
| same as check, but for a particular height, rather than the top More... | |
| bool | add (const cryptonote::block &block, uint64_t height) |
| add a new block More... | |
| bool | reorganize_from_block_height (uint64_t height) |
| called when the blockchain is reorganized More... | |
| bool | reorganize_from_chain_height (uint64_t height) |
| void | on_block_popped (uint64_t new_chain_height) |
| called when one or more blocks are popped from the blockchain More... | |
| State | get_state (time_t t) const |
| returns current state at the given time More... | |
| State | get_state () const |
| uint8_t | get (uint64_t height) const |
| returns the hard fork version for the given block height More... | |
| uint8_t | get_ideal_version () const |
| returns the latest "ideal" version More... | |
| uint8_t | get_ideal_version (uint64_t height) const |
| returns the "ideal" version for a given height More... | |
| uint8_t | get_next_version () const |
| returns the next version More... | |
| uint8_t | get_current_version () const |
| returns the current version More... | |
| uint64_t | get_earliest_ideal_height_for_version (uint8_t version) const |
| returns the earliest block a given version may activate More... | |
| bool | get_voting_info (uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const |
| returns information about current voting state More... | |
| uint64_t | get_window_size () const |
| returns the size of the voting window in blocks More... | |
Static Public Attributes | |
| static const uint64_t | DEFAULT_ORIGINAL_VERSION_TILL_HEIGHT = 0 |
| static const time_t | DEFAULT_FORKED_TIME = 31557600 |
| static const time_t | DEFAULT_UPDATE_TIME = 31557600 / 2 |
| static const uint64_t | DEFAULT_WINDOW_SIZE = 10080 |
| static const uint8_t | DEFAULT_THRESHOLD_PERCENT = 80 |
Definition at line 39 of file hardfork.h.
| Enumerator | |
|---|---|
| LikelyForked | |
| UpdateNeeded | |
| Ready | |
Definition at line 42 of file hardfork.h.
| HardFork::HardFork | ( | cryptonote::BlockchainDB & | db, |
| uint8_t | original_version = 1, |
||
| uint64_t | original_version_till_height = DEFAULT_ORIGINAL_VERSION_TILL_HEIGHT, |
||
| time_t | forked_time = DEFAULT_FORKED_TIME, |
||
| time_t | update_time = DEFAULT_UPDATE_TIME, |
||
| uint64_t | window_size = DEFAULT_WINDOW_SIZE, |
||
| uint8_t | default_threshold_percent = DEFAULT_THRESHOLD_PERCENT |
||
| ) |
creates a new HardFork object
| original_version | the block version for blocks 0 through to the first fork |
| forked_time | the time in seconds before thinking we're forked |
| update_time | the time in seconds before thinking we need to update |
| window_size | the size of the window in blocks to consider for version voting |
| default_threshold_percent | the size of the majority in percents |
Definition at line 58 of file hardfork.cpp.
| bool HardFork::add | ( | const cryptonote::block & | block, |
| uint64_t | height | ||
| ) |
add a new block
returns true if no error, false otherwise
| block | the new block |
Definition at line 164 of file hardfork.cpp.

add a new hardfork height
returns true if no error, false otherwise
| version | the major block version for the fork |
| height | The height the hardfork takes effect |
| threshold | The threshold of votes needed for this fork (0-100) |
| time | Approximate time of the hardfork (seconds since epoch) |
Definition at line 74 of file hardfork.cpp.

add a new hardfork height
returns true if no error, false otherwise
| version | the major block version for the fork |
| height | The height the hardfork takes effect |
| time | Approximate time of the hardfork (seconds since epoch) |
Definition at line 95 of file hardfork.cpp.

| bool HardFork::check | ( | const cryptonote::block & | block | ) | const |
check whether a new block would be accepted
returns true if the block is accepted, false otherwise
| block | the new block |
This check is made by add. It is exposed publicly to allow the caller to inexpensively check whether a block would be accepted or rejected by its version number. Indeed, if this check could only be done as part of add, the caller would either have to add the block to the blockchain first, then call add, then have to pop the block from the blockchain if its version did not satisfy the hard fork requirements, or call add first, then, if the hard fork requirements are met, add the block to the blockchain, upon which a failure (the block being invalid, double spending, etc) would cause the hardfork object to reorganize.
Definition at line 116 of file hardfork.cpp.
| bool HardFork::check_for_height | ( | const cryptonote::block & | block, |
| uint64_t | height | ||
| ) | const |
same as check, but for a particular height, rather than the top
NOTE: this does not play well with voting, and relies on voting to be disabled (that is, forks happen on the scheduled date, whether or not enough blocks have voted for the fork).
returns true if no error, false otherwise
| block | the new block |
| height | which height to check for |
Definition at line 129 of file hardfork.cpp.

returns the hard fork version for the given block height
| height | height of the block to check |
Definition at line 348 of file hardfork.cpp.


| uint8_t HardFork::get_current_version | ( | ) | const |
returns the current version
This is the latest version that's past its trigger date and had enough votes at one point in the past.
Definition at line 361 of file hardfork.cpp.

returns the earliest block a given version may activate
Definition at line 384 of file hardfork.cpp.

| uint8_t HardFork::get_ideal_version | ( | ) | const |
returns the latest "ideal" version
This is the latest version that's been scheduled
Definition at line 367 of file hardfork.cpp.

returns the "ideal" version for a given height
| height | height of the block to check |
Definition at line 373 of file hardfork.cpp.
| uint8_t HardFork::get_next_version | ( | ) | const |
returns the next version
This is the version which will we fork to next
Definition at line 397 of file hardfork.cpp.


| HardFork::State HardFork::get_state | ( | time_t | t | ) | const |
returns current state at the given time
Based on the approximate time of the last known hard fork, estimate whether we need to update, or if we're way behind
| t | the time to consider |
Definition at line 327 of file hardfork.cpp.

| HardFork::State HardFork::get_state | ( | ) | const |
Definition at line 343 of file hardfork.cpp.
| bool HardFork::get_voting_info | ( | uint8_t | version, |
| uint32_t & | window, | ||
| uint32_t & | votes, | ||
| uint32_t & | threshold, | ||
| uint64_t & | earliest_height, | ||
| uint8_t & | voting | ||
| ) | const |
returns information about current voting state
returns true if the given version is enabled (ie, the current version is at least the passed version), false otherwise
| version | the version to check voting for |
| window | the number of blocks considered in voting |
| votes | number of votes for next version |
| threshold | number of votes needed to switch to next version |
| earliest_height | earliest height at which the version can take effect |
Definition at line 409 of file hardfork.cpp.


|
inline |
returns the size of the voting window in blocks
Definition at line 232 of file hardfork.h.
| void HardFork::init | ( | ) |
initialize the object
Must be done after adding all the required hardforks via add above
Definition at line 169 of file hardfork.cpp.


| void HardFork::on_block_popped | ( | uint64_t | new_chain_height | ) |
called when one or more blocks are popped from the blockchain
The current fork will be updated by looking up the db, which is much cheaper than recomputing everything
| new_chain_height | the height of the chain after popping |
Definition at line 287 of file hardfork.cpp.

called when the blockchain is reorganized
This will rescan the blockchain to determine which hard forks have been triggered
returns true if no error, false otherwise
| blockchain | the blockchain |
| height | of the last block kept from the previous blockchain |
Definition at line 202 of file hardfork.cpp.


Definition at line 242 of file hardfork.cpp.

|
static |
Definition at line 49 of file hardfork.h.
|
static |
Definition at line 48 of file hardfork.h.
|
static |
Definition at line 52 of file hardfork.h.
|
static |
Definition at line 50 of file hardfork.h.
|
static |
Definition at line 51 of file hardfork.h.