Replace fc::uint128 with boost::multiprecision::uint128_t
This commit is contained in:
parent
6514f8fadd
commit
f25c4f6ae6
29 changed files with 58 additions and 66 deletions
|
|
@ -37,6 +37,7 @@
|
||||||
#include <graphene/chain/worker_object.hpp>
|
#include <graphene/chain/worker_object.hpp>
|
||||||
#include <graphene/chain/tournament_object.hpp>
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
||||||
|
#include <fc/crypto/base64.hpp>
|
||||||
#include <fc/crypto/hex.hpp>
|
#include <fc/crypto/hex.hpp>
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
#include <fc/rpc/api_connection.hpp>
|
#include <fc/rpc/api_connection.hpp>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
#include <boost/range/iterator_range.hpp>
|
#include <boost/range/iterator_range.hpp>
|
||||||
#include <boost/rational.hpp>
|
#include <boost/rational.hpp>
|
||||||
#include <boost/multiprecision/cpp_int.hpp>
|
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p)
|
||||||
if( p == GRAPHENE_100_PERCENT )
|
if( p == GRAPHENE_100_PERCENT )
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
fc::uint128 r(a.value);
|
fc::uint128_t r = a.value;
|
||||||
r *= p;
|
r *= p;
|
||||||
r /= GRAPHENE_100_PERCENT;
|
r /= GRAPHENE_100_PERCENT;
|
||||||
return r.to_uint64();
|
return r.convert_to<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void account_balance_object::adjust_balance(const asset& delta)
|
void account_balance_object::adjust_balance(const asset& delta)
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,11 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu
|
||||||
if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT )
|
if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT )
|
||||||
return current_supply + force_settled_volume;
|
return current_supply + force_settled_volume;
|
||||||
|
|
||||||
fc::uint128 volume = current_supply.value + force_settled_volume.value;
|
fc::uint128_t volume = current_supply.value;
|
||||||
|
volume += force_settled_volume.value;
|
||||||
volume *= options.maximum_force_settlement_volume;
|
volume *= options.maximum_force_settlement_volume;
|
||||||
volume /= GRAPHENE_100_PERCENT;
|
volume /= GRAPHENE_100_PERCENT;
|
||||||
return volume.to_uint64();
|
return volume.convert_to<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time)
|
void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
|
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
#include <fc/crypto/digest.hpp>
|
#include <fc/crypto/digest.hpp>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
@ -614,7 +613,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
p.time = genesis_state.initial_timestamp;
|
p.time = genesis_state.initial_timestamp;
|
||||||
p.dynamic_flags = 0;
|
p.dynamic_flags = 0;
|
||||||
p.witness_budget = 0;
|
p.witness_budget = 0;
|
||||||
p.recent_slots_filled = fc::uint128::max_value();
|
p.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max();
|
||||||
});
|
});
|
||||||
create<global_betting_statistics_object>([&](global_betting_statistics_object& betting_statistics) {
|
create<global_betting_statistics_object>([&](global_betting_statistics_object& betting_statistics) {
|
||||||
betting_statistics.number_of_active_events = 0;
|
betting_statistics.number_of_active_events = 0;
|
||||||
|
|
@ -989,7 +988,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
|
|
||||||
_wso.last_scheduling_block = 0;
|
_wso.last_scheduling_block = 0;
|
||||||
|
|
||||||
_wso.recent_slots_filled = fc::uint128::max_value();
|
_wso.recent_slots_filled = fc::uint128_t::max_value();
|
||||||
|
|
||||||
// for shuffled
|
// for shuffled
|
||||||
for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/multiprecision/integer.hpp>
|
|
||||||
|
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
#include <fc/uint128.hpp>
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
|
|
@ -184,10 +182,10 @@ void database::pay_workers( share_type& budget )
|
||||||
// Note: if there is a good chance that passed_time_count == day_count,
|
// Note: if there is a good chance that passed_time_count == day_count,
|
||||||
// for better performance, can avoid the 128 bit calculation by adding a check.
|
// for better performance, can avoid the 128 bit calculation by adding a check.
|
||||||
// Since it's not the case on BitShares mainnet, we're not using a check here.
|
// Since it's not the case on BitShares mainnet, we're not using a check here.
|
||||||
fc::uint128 pay(requested_pay.value);
|
fc::uint128_t pay = requested_pay.value;
|
||||||
pay *= passed_time_count;
|
pay *= passed_time_count;
|
||||||
pay /= day_count;
|
pay /= day_count;
|
||||||
requested_pay = pay.to_uint64();
|
requested_pay = pay.convert_to<uint64_t>();
|
||||||
|
|
||||||
share_type actual_pay = std::min(budget, requested_pay);
|
share_type actual_pay = std::min(budget, requested_pay);
|
||||||
//ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay));
|
//ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay));
|
||||||
|
|
@ -436,7 +434,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record&
|
||||||
budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS;
|
budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS;
|
||||||
share_type budget;
|
share_type budget;
|
||||||
if( budget_u128 < reserve.value )
|
if( budget_u128 < reserve.value )
|
||||||
rec.total_budget = share_type(budget_u128.to_uint64());
|
rec.total_budget = share_type(budget_u128.convert_to<uint64_t>());
|
||||||
else
|
else
|
||||||
rec.total_budget = reserve;
|
rec.total_budget = reserve;
|
||||||
|
|
||||||
|
|
@ -491,7 +489,7 @@ void database::process_budget()
|
||||||
if( worker_budget_u128 >= available_funds.value )
|
if( worker_budget_u128 >= available_funds.value )
|
||||||
worker_budget = available_funds;
|
worker_budget = available_funds;
|
||||||
else
|
else
|
||||||
worker_budget = worker_budget_u128.to_uint64();
|
worker_budget = worker_budget_u128.convert_to<uint64_t>();
|
||||||
rec.worker_budget = worker_budget;
|
rec.worker_budget = worker_budget;
|
||||||
available_funds -= worker_budget;
|
available_funds -= worker_budget;
|
||||||
|
|
||||||
|
|
@ -631,12 +629,12 @@ void split_fba_balance(
|
||||||
fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value;
|
fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value;
|
||||||
buyback_amount_128 *= designated_asset_buyback_pct;
|
buyback_amount_128 *= designated_asset_buyback_pct;
|
||||||
buyback_amount_128 /= GRAPHENE_100_PERCENT;
|
buyback_amount_128 /= GRAPHENE_100_PERCENT;
|
||||||
share_type buyback_amount = buyback_amount_128.to_uint64();
|
share_type buyback_amount = buyback_amount_128.convert_to<uint64_t>();
|
||||||
|
|
||||||
fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value;
|
fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value;
|
||||||
issuer_amount_128 *= designated_asset_issuer_pct;
|
issuer_amount_128 *= designated_asset_issuer_pct;
|
||||||
issuer_amount_128 /= GRAPHENE_100_PERCENT;
|
issuer_amount_128 /= GRAPHENE_100_PERCENT;
|
||||||
share_type issuer_amount = issuer_amount_128.to_uint64();
|
share_type issuer_amount = issuer_amount_128.convert_to<uint64_t>();
|
||||||
|
|
||||||
// this assert should never fail
|
// this assert should never fail
|
||||||
FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees );
|
FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees );
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,7 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass
|
||||||
if( trade_asset.options.market_fee_percent == 0 )
|
if( trade_asset.options.market_fee_percent == 0 )
|
||||||
return trade_asset.amount(0);
|
return trade_asset.amount(0);
|
||||||
|
|
||||||
fc::uint128 a(trade_amount.amount.value);
|
fc::uint128_t a(trade_amount.amount.value);
|
||||||
a *= trade_asset.options.market_fee_percent;
|
a *= trade_asset.options.market_fee_percent;
|
||||||
a /= GRAPHENE_100_PERCENT;
|
a /= GRAPHENE_100_PERCENT;
|
||||||
asset percent_fee = trade_asset.amount(a.to_uint64());
|
asset percent_fee = trade_asset.amount(a.to_uint64());
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@
|
||||||
|
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
|
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks )
|
void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks )
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
#include <graphene/chain/witness_schedule_object.hpp>
|
#include <graphene/chain/witness_schedule_object.hpp>
|
||||||
|
|
||||||
|
#include <fc/popcount.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
using boost::container::flat_set;
|
using boost::container::flat_set;
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,6 @@
|
||||||
#include <graphene/chain/market_evaluator.hpp>
|
#include <graphene/chain/market_evaluator.hpp>
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
|
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
database& generic_evaluator::db()const { return trx_state->db(); }
|
database& generic_evaluator::db()const { return trx_state->db(); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode
|
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
|
|
||||||
|
#include <fc/io/raw.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
chain_id_type genesis_state_type::compute_chain_id() const
|
chain_id_type genesis_state_type::compute_chain_id() const
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,6 @@ namespace graphene { namespace chain {
|
||||||
* every time a block is found it decreases by
|
* every time a block is found it decreases by
|
||||||
* RECENTLY_MISSED_COUNT_DECREMENT. It is
|
* RECENTLY_MISSED_COUNT_DECREMENT. It is
|
||||||
* never less than 0.
|
* never less than 0.
|
||||||
*
|
|
||||||
* If the recently_missed_count hits 2*UNDO_HISTORY then no new blocks may be pushed.
|
|
||||||
*/
|
*/
|
||||||
uint32_t recently_missed_count = 0;
|
uint32_t recently_missed_count = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
#include <fc/string.hpp>
|
#include <fc/string.hpp>
|
||||||
#include <fc/io/datastream.hpp>
|
#include <fc/io/datastream.hpp>
|
||||||
#include <fc/io/raw_fwd.hpp>
|
#include <fc/io/raw_fwd.hpp>
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
#include <fc/static_variant.hpp>
|
#include <fc/static_variant.hpp>
|
||||||
#include <fc/smart_ref_fwd.hpp>
|
#include <fc/smart_ref_fwd.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,11 +89,11 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
struct cdd_vesting_policy
|
struct cdd_vesting_policy
|
||||||
{
|
{
|
||||||
uint32_t vesting_seconds = 0;
|
uint32_t vesting_seconds = 0;
|
||||||
fc::uint128_t coin_seconds_earned;
|
fc::uint128_t coin_seconds_earned;
|
||||||
/** while coindays may accrue over time, none may be claimed before first_claim date */
|
/** while coindays may accrue over time, none may be claimed before first_claim date */
|
||||||
fc::time_point_sec start_claim;
|
fc::time_point_sec start_claim;
|
||||||
fc::time_point_sec coin_seconds_earned_last_update;
|
fc::time_point_sec coin_seconds_earned_last_update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute coin_seconds_earned. Used to
|
* Compute coin_seconds_earned. Used to
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
#include <graphene/chain/protocol/market.hpp>
|
#include <graphene/chain/protocol/market.hpp>
|
||||||
|
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <boost/rational.hpp>
|
#include <boost/rational.hpp>
|
||||||
#include <boost/multiprecision/cpp_int.hpp>
|
#include <boost/multiprecision/cpp_int.hpp>
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
typedef boost::multiprecision::uint128_t uint128_t;
|
typedef boost::multiprecision::uint128_t uint128_t;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ namespace fc
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
#define MAX_FEE_STABILIZATION_ITERATION 4
|
#define MAX_FEE_STABILIZATION_ITERATION 4
|
||||||
|
|
||||||
|
|
@ -131,7 +132,7 @@ namespace graphene { namespace chain {
|
||||||
auto itr = parameters.find(params);
|
auto itr = parameters.find(params);
|
||||||
if( itr != parameters.end() ) params = *itr;
|
if( itr != parameters.end() ) params = *itr;
|
||||||
auto base_value = op.visit( calc_fee_visitor( params ) );
|
auto base_value = op.visit( calc_fee_visitor( params ) );
|
||||||
auto scaled = fc::uint128(base_value) * scale;
|
auto scaled = fc::uint128_t(base_value) * scale;
|
||||||
scaled /= GRAPHENE_100_PERCENT;
|
scaled /= GRAPHENE_100_PERCENT;
|
||||||
FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
|
FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||||
//idump( (base_value)(scaled)(core_exchange_rate) );
|
//idump( (base_value)(scaled)(core_exchange_rate) );
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,15 @@
|
||||||
#include <graphene/chain/protocol/operations.hpp>
|
#include <graphene/chain/protocol/operations.hpp>
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte )
|
uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte )
|
||||||
{
|
{
|
||||||
auto result = (fc::uint128(bytes) * price_per_kbyte) / 1024;
|
auto result = (fc::uint128_t(bytes) * price_per_kbyte) / 1024;
|
||||||
FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY );
|
FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||||
return result.to_uint64();
|
return result.convert_to<uint64_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void balance_claim_operation::validate()const
|
void balance_claim_operation::validate()const
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ asset cdd_vesting_policy::get_allowed_withdraw(const vesting_policy_context& ctx
|
||||||
fc::uint128_t cs_earned = compute_coin_seconds_earned(ctx);
|
fc::uint128_t cs_earned = compute_coin_seconds_earned(ctx);
|
||||||
fc::uint128_t withdraw_available = cs_earned / std::max(vesting_seconds, 1u);
|
fc::uint128_t withdraw_available = cs_earned / std::max(vesting_seconds, 1u);
|
||||||
assert(withdraw_available <= ctx.balance.amount.value);
|
assert(withdraw_available <= ctx.balance.amount.value);
|
||||||
return asset(withdraw_available.to_uint64(), ctx.balance.asset_id);
|
return asset(static_cast<uint64_t>(withdraw_available), ctx.balance.asset_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cdd_vesting_policy::on_deposit(const vesting_policy_context& ctx)
|
void cdd_vesting_policy::on_deposit(const vesting_policy_context& ctx)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace graphene { namespace chain {
|
||||||
using boost::multi_index_container;
|
using boost::multi_index_container;
|
||||||
using namespace boost::multi_index;
|
using namespace boost::multi_index;
|
||||||
|
|
||||||
struct by_id{};
|
struct by_id;
|
||||||
/**
|
/**
|
||||||
* Almost all objects can be tracked and managed via a boost::multi_index container that uses
|
* Almost all objects can be tracked and managed via a boost::multi_index container that uses
|
||||||
* an unordered_unique key on the object ID. This template class adapts the generic index interface
|
* an unordered_unique key on the object ID. This template class adapts the generic index interface
|
||||||
|
|
@ -112,18 +112,7 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
const index_type& indices()const { return _indices; }
|
const index_type& indices()const { return _indices; }
|
||||||
|
|
||||||
virtual fc::uint128 hash()const override {
|
|
||||||
fc::uint128 result;
|
|
||||||
for( const auto& ptr : _indices )
|
|
||||||
{
|
|
||||||
result += ptr.hash();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fc::uint128 _current_hash;
|
|
||||||
index_type _indices;
|
index_type _indices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void inspect_all_objects(std::function<void(const object&)> inspector)const = 0;
|
virtual void inspect_all_objects(std::function<void(const object&)> inspector)const = 0;
|
||||||
virtual fc::uint128 hash()const = 0;
|
|
||||||
virtual void add_observer( const shared_ptr<index_observer>& ) = 0;
|
virtual void add_observer( const shared_ptr<index_observer>& ) = 0;
|
||||||
|
|
||||||
virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0;
|
virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0;
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <graphene/db/object_id.hpp>
|
#include <graphene/db/object_id.hpp>
|
||||||
|
#include <boost/multiprecision/integer.hpp>
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
#include <fc/crypto/city.hpp>
|
#include <fc/crypto/city.hpp>
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
|
|
||||||
#define MAX_NESTING (200)
|
#define MAX_NESTING (200)
|
||||||
|
|
||||||
|
|
@ -77,7 +77,6 @@ namespace graphene { namespace db {
|
||||||
virtual void move_from( object& obj ) = 0;
|
virtual void move_from( object& obj ) = 0;
|
||||||
virtual variant to_variant()const = 0;
|
virtual variant to_variant()const = 0;
|
||||||
virtual vector<char> pack()const = 0;
|
virtual vector<char> pack()const = 0;
|
||||||
virtual fc::uint128 hash()const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -102,10 +101,6 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this), MAX_NESTING ); }
|
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this), MAX_NESTING ); }
|
||||||
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }
|
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }
|
||||||
virtual fc::uint128 hash()const {
|
|
||||||
auto tmp = this->pack();
|
|
||||||
return fc::city_hash_crc_128( tmp.data(), tmp.size() );
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef flat_map<uint8_t, object_id_type> annotation_map;
|
typedef flat_map<uint8_t, object_id_type> annotation_map;
|
||||||
|
|
@ -139,6 +134,13 @@ namespace graphene { namespace db {
|
||||||
|
|
||||||
} } // graphene::db
|
} } // graphene::db
|
||||||
|
|
||||||
|
// Without this, pack(object_id) tries to match the template for
|
||||||
|
// pack(boost::multiprecision::uint128_t). No idea why. :-(
|
||||||
|
namespace boost { namespace multiprecision { namespace detail {
|
||||||
|
template<typename To>
|
||||||
|
struct is_restricted_conversion<graphene::db::object,To> : public mpl::true_ {};
|
||||||
|
}}}
|
||||||
|
|
||||||
FC_REFLECT_TYPENAME( graphene::db::annotation_map )
|
FC_REFLECT_TYPENAME( graphene::db::annotation_map )
|
||||||
FC_REFLECT( graphene::db::object, (id) )
|
FC_REFLECT( graphene::db::object, (id) )
|
||||||
FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object<Derived>, (graphene::db::object), (annotations) )
|
FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object<Derived>, (graphene::db::object), (annotations) )
|
||||||
|
|
|
||||||
|
|
@ -98,13 +98,6 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
} FC_CAPTURE_AND_RETHROW()
|
} FC_CAPTURE_AND_RETHROW()
|
||||||
}
|
}
|
||||||
virtual fc::uint128 hash()const override {
|
|
||||||
fc::uint128 result;
|
|
||||||
for( const auto& ptr : _objects )
|
|
||||||
result += ptr->hash();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
#include <fc/container/flat.hpp>
|
#include <fc/container/flat.hpp>
|
||||||
#include <fc/uint128.hpp>
|
|
||||||
|
|
||||||
namespace graphene { namespace db {
|
namespace graphene { namespace db {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9fa98d9a93ada3e84f48812b5c42b053b0dbf9da
|
Subproject commit 69ebbf4ba490482956de0e331b22f1018747d789
|
||||||
|
|
@ -123,7 +123,6 @@ typedef multi_index_container<
|
||||||
>
|
>
|
||||||
> order_history_multi_index_type;
|
> order_history_multi_index_type;
|
||||||
|
|
||||||
|
|
||||||
typedef generic_index<bucket_object, bucket_object_multi_index_type> bucket_index;
|
typedef generic_index<bucket_object, bucket_object_multi_index_type> bucket_index;
|
||||||
typedef generic_index<order_history_object, order_history_multi_index_type> history_index;
|
typedef generic_index<order_history_object, order_history_multi_index_type> history_index;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,13 @@
|
||||||
#include <fc/crypto/hex.hpp>
|
#include <fc/crypto/hex.hpp>
|
||||||
#include <fc/thread/mutex.hpp>
|
#include <fc/thread/mutex.hpp>
|
||||||
#include <fc/thread/scoped_lock.hpp>
|
#include <fc/thread/scoped_lock.hpp>
|
||||||
|
<<<<<<< HEAD
|
||||||
#include <fc/crypto/rand.hpp>
|
#include <fc/crypto/rand.hpp>
|
||||||
|
=======
|
||||||
|
#include <fc/rpc/api_connection.hpp>
|
||||||
|
#include <fc/crypto/base58.hpp>
|
||||||
|
#include <fc/popcount.hpp>
|
||||||
|
>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t
|
||||||
|
|
||||||
#include <graphene/app/api.hpp>
|
#include <graphene/app/api.hpp>
|
||||||
#include <graphene/chain/asset_object.hpp>
|
#include <graphene/chain/asset_object.hpp>
|
||||||
|
|
@ -680,7 +686,13 @@ public:
|
||||||
" old");
|
" old");
|
||||||
result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time);
|
result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time);
|
||||||
result["chain_id"] = chain_props.chain_id;
|
result["chain_id"] = chain_props.chain_id;
|
||||||
|
<<<<<<< HEAD
|
||||||
result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0;
|
result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0;
|
||||||
|
=======
|
||||||
|
stringstream participation;
|
||||||
|
participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0;
|
||||||
|
result["participation"] = participation.str();
|
||||||
|
>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t
|
||||||
result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS);
|
result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS);
|
||||||
result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS);
|
result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS);
|
||||||
result["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS);
|
result["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS);
|
||||||
|
|
|
||||||
|
|
@ -1030,9 +1030,9 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture )
|
||||||
{
|
{
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
auto rsf = [&]() -> string
|
auto rsf = [this]() -> string
|
||||||
{
|
{
|
||||||
fc::uint128 rsf;
|
fc::uint128_t rsf;
|
||||||
if (db.get_global_properties().parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM)
|
if (db.get_global_properties().parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM)
|
||||||
rsf = db.get(witness_schedule_id_type()).recent_slots_filled;
|
rsf = db.get(witness_schedule_id_type()).recent_slots_filled;
|
||||||
else
|
else
|
||||||
|
|
@ -1041,7 +1041,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture )
|
||||||
result.reserve(128);
|
result.reserve(128);
|
||||||
for( int i=0; i<128; i++ )
|
for( int i=0; i<128; i++ )
|
||||||
{
|
{
|
||||||
result += ((rsf.lo & 1) == 0) ? '0' : '1';
|
result += rsf & 1 ? '1' : '0';
|
||||||
rsf >>= 1;
|
rsf >>= 1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
#include <graphene/chain/vesting_balance_object.hpp>
|
#include <graphene/chain/vesting_balance_object.hpp>
|
||||||
#include <graphene/chain/exceptions.hpp>
|
#include <graphene/chain/exceptions.hpp>
|
||||||
|
|
||||||
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "../common/database_fixture.hpp"
|
#include "../common/database_fixture.hpp"
|
||||||
|
|
@ -245,7 +247,7 @@ uint64_t pct( uint64_t percentage, uint64_t val )
|
||||||
fc::uint128_t x = percentage;
|
fc::uint128_t x = percentage;
|
||||||
x *= val;
|
x *= val;
|
||||||
x /= GRAPHENE_100_PERCENT;
|
x /= GRAPHENE_100_PERCENT;
|
||||||
return x.to_uint64();
|
return static_cast<uint64_t>(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t pct( uint64_t percentage0, uint64_t percentage1, uint64_t val )
|
uint64_t pct( uint64_t percentage0, uint64_t percentage1, uint64_t val )
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue