Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1 from Infinium-dev/development
Infinium v2.0.2 Release
  • Loading branch information
Infinium-dev committed Nov 10, 2020
2 parents 106ce66 + cdbb79c commit b4d080c
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 217 deletions.
9 changes: 7 additions & 2 deletions src/Core/BlockChainState.cpp
Expand Up @@ -16,6 +16,7 @@
#include "platform/Time.hpp"
#include "seria/BinaryInputStream.hpp"
#include "seria/BinaryOutputStream.hpp"
#include "CryptoNoteConfig.hpp"

static const std::string KEYIMAGE_PREFIX = "i";
static const std::string AMOUNT_OUTPUT_PREFIX = "a"; // amount:si -> g_index
Expand Down Expand Up @@ -407,19 +408,23 @@ void BlockChainState::check_standalone_consensus(
}
info->already_generated_key_outputs = prev_info.already_generated_key_outputs + key_outputs_count;

Amount divide_by = cn::parameters::MAX_SUPPLY_RPC_DIVIDE_BY;

if (is_amethyst) {
info->base_reward = m_currency.get_base_block_reward(
block.header.major_version, info->height, prev_info.already_generated_coins, diff_for_reward);
info->reward = info->base_reward + info->transactions_fee;
info->already_generated_coins = prev_info.already_generated_coins + info->base_reward;
info->already_generated_coins = prev_info.already_generated_coins + ((info->base_reward)/divide_by);
} else {
SignedAmount emission_change = 0;
SignedAmount block_reward_oldV1 = 0;
info->base_reward = m_currency.get_block_reward(block.header.major_version, info->height,
info->effective_size_median, 0, prev_info.already_generated_coins, 0, &emission_change, diff_for_reward);
block_reward_oldV1 = info->base_reward;
info->reward =
m_currency.get_block_reward(block.header.major_version, info->height, info->effective_size_median,
info->transactions_size, prev_info.already_generated_coins, info->transactions_fee, &emission_change, diff_for_reward);
info->already_generated_coins = prev_info.already_generated_coins + emission_change;
info->already_generated_coins = prev_info.already_generated_coins + (block_reward_oldV1/divide_by);
}

if (miner_reward != info->reward)
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Currency.cpp
Expand Up @@ -289,7 +289,7 @@ namespace
}

Amount Currency::get_base_block_reward(
uint8_t block_major_version, Height height, Amount already_generated_coins, Difficulty diff) const {
uint8_t block_major_version, Height height, AmountSupply already_generated_coins, Difficulty diff) const {
/*invariant(already_generated_coins <= money_supply, "");
invariant(emission_speed_factor > 0 && emission_speed_factor <= 8 * sizeof(Amount), "");
Expand All @@ -306,7 +306,7 @@ Amount Currency::get_base_block_reward(
}

Amount Currency::get_block_reward(uint8_t block_major_version, Height height, size_t effective_median_size,
size_t current_transactions_size, Amount already_generated_coins, Amount fee, SignedAmount *emission_change, Difficulty diff) const {
size_t current_transactions_size, AmountSupply already_generated_coins, Amount fee, SignedAmount *emission_change, Difficulty diff) const {
Amount base_reward = get_base_block_reward(block_major_version, height, already_generated_coins, diff);

Amount penalized_base_reward = get_penalized_amount(base_reward, effective_median_size, current_transactions_size);
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Currency.hpp
Expand Up @@ -88,9 +88,9 @@ class Currency { // Consensus calculations depend on those parameters
PublicKey get_checkpoint_public_key(size_t key_id) const;
size_t get_checkpoint_keys_count() const { return checkpoint_keys_end - checkpoint_keys_begin; }

Amount get_base_block_reward(uint8_t block_major_version, Height height, Amount already_generated_coins, Difficulty diff) const;
Amount get_base_block_reward(uint8_t block_major_version, Height height, AmountSupply already_generated_coins, Difficulty diff) const;
Amount get_block_reward(uint8_t block_major_version, Height height, size_t effective_median_size,
size_t current_transactions_size, Amount already_generated_coins, Amount fee,
size_t current_transactions_size, AmountSupply already_generated_coins, Amount fee,
SignedAmount *emission_change = nullptr, Difficulty diff=1000) const;
Transaction construct_miner_tx(const Hash &miner_secret, uint8_t block_major_version, Height height,
Amount block_reward, const AccountAddress &miner_address) const;
Expand Down
1 change: 1 addition & 0 deletions src/CryptoNote.hpp
Expand Up @@ -36,6 +36,7 @@ using namespace std::placeholders; // We enjoy standard bindings
typedef uint32_t Height;
typedef uint64_t Difficulty;
typedef uint64_t Amount;
typedef uint64_t AmountSupply;
typedef uint32_t Timestamp;
typedef uint64_t BlockOrTimestamp;
// Height or Timestamp, 32-bit is enough, but historically we already have several very large values in blockchain
Expand Down
420 changes: 211 additions & 209 deletions src/CryptoNoteConfig.hpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/rpc_api.cpp
Expand Up @@ -6,6 +6,7 @@
#include "Core/TransactionExtra.hpp"
#include "common/Varint.hpp"
#include "seria/JsonOutputStream.hpp"
#include "CryptoNoteConfig.hpp"

using namespace cn;

Expand Down Expand Up @@ -102,6 +103,7 @@ void ser_members(api::Output &v, ISeria &s, bool only_infiniumd_fields) {
}

void ser_members(api::BlockHeader &v, ISeria &s) {
Amount total_supply_remove_decimals = cn::parameters::MAX_SUPPLY_RPC_DIVIDE_BY;
seria_kv("major_version", v.major_version, s);
seria_kv("minor_version", v.minor_version, s);
seria_kv("timestamp", v.timestamp, s);
Expand All @@ -126,6 +128,7 @@ void ser_members(api::BlockHeader &v, ISeria &s) {
seria_kv("block_size", v.block_size, s);
seria_kv("transactions_size", v.transactions_size, s);
seria_kv("already_generated_coins", v.already_generated_coins, s);
seria_kv("already_generated_coins_multiply_by", total_supply_remove_decimals, s);
seria_kv("already_generated_transactions", v.already_generated_transactions, s);
seria_kv("already_generated_key_outputs", v.already_generated_key_outputs, s);
seria_kv("block_capacity_vote", v.block_capacity_vote, s);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc_api.hpp
Expand Up @@ -112,7 +112,7 @@ struct BlockHeader {
size_t block_size = 0;
size_t transactions_size = 0;

Amount already_generated_coins = 0;
AmountSupply already_generated_coins = 0;
size_t already_generated_transactions = 0;
size_t already_generated_key_outputs = 0;
size_t size_median = 0; // median of transactions_size, 0 in amethyst
Expand Down
2 changes: 1 addition & 1 deletion src/version.hpp
Expand Up @@ -5,7 +5,7 @@

// defines are for Windows resource compiler
#define infinium_VERSION_WINDOWS_COMMA 3, 19, 4, 18
#define infinium_VERSION_STRING "v2.0.1 (New Chance)"
#define infinium_VERSION_STRING "v2.0.2 (New Chance)"

#ifndef RC_INVOKED // Windows resource compiler

Expand Down

0 comments on commit b4d080c

Please sign in to comment.