remove smart_ref

This commit is contained in:
sierra19XX 2020-10-18 02:32:21 +11:00
parent 959474610f
commit 4c153d5418
43 changed files with 32 additions and 91 deletions

View file

@ -38,7 +38,6 @@
#include <graphene/chain/tournament_object.hpp>
#include <fc/crypto/hex.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/thread/future.hpp>

View file

@ -37,8 +37,6 @@
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/worker_evaluator.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/io/fstream.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/rpc/websocket_api.hpp>
@ -80,7 +78,7 @@ namespace detail {
auto nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key)));
genesis_state_type initial_state;
initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION);
initial_state.initial_parameters.current_fees = std::make_shared<fee_schedule>(fee_schedule::get_default());
initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT;
initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() /
initial_state.initial_parameters.block_interval *

View file

@ -30,7 +30,6 @@
#include <graphene/chain/pts_address.hpp>
#include <fc/bloom_filter.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp>

View file

@ -43,6 +43,7 @@ add_library( graphene_chain
protocol/assert.cpp
protocol/account.cpp
protocol/transfer.cpp
protocol/chain_parameters.cpp
protocol/committee_member.cpp
protocol/witness.cpp
protocol/market.cpp

View file

@ -22,8 +22,6 @@
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include <graphene/chain/account_evaluator.hpp>
#include <graphene/chain/buyback.hpp>
#include <graphene/chain/buyback_object.hpp>

View file

@ -24,7 +24,6 @@
#include <graphene/chain/block_database.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {

View file

@ -30,8 +30,6 @@
#include <graphene/chain/protocol/vote.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {
void_result committee_member_create_evaluator::do_evaluate( const committee_member_create_operation& op )

View file

@ -29,8 +29,6 @@
#include <graphene/chain/fba_accumulator_id.hpp>
#include <graphene/chain/hardfork.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {
void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o )

View file

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include "db_balance.cpp"
#include "db_bet.cpp"
#include "db_block.cpp"

View file

@ -42,8 +42,6 @@
#include <graphene/chain/witness_schedule_object.hpp>
#include <fc/crypto/digest.hpp>
#include <fc/smart_ref_impl.hpp>
namespace {
struct proposed_operations_digest_accumulator

View file

@ -34,8 +34,6 @@
#include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_proposal_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <ctime>
#include <algorithm>
@ -68,7 +66,7 @@ const dynamic_global_property_object& database::get_dynamic_global_properties()
const fee_schedule& database::current_fee_schedule()const
{
return get_global_properties().parameters.current_fees;
return std::ref( *get_global_properties().parameters.current_fees );
}
time_point_sec database::head_block_time()const

View file

@ -103,7 +103,6 @@
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>
#include <fc/crypto/digest.hpp>

View file

@ -24,7 +24,6 @@
#include <boost/multiprecision/integer.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>
#include <graphene/chain/database.hpp>

View file

@ -24,7 +24,6 @@
#include <graphene/chain/fork_database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {
fork_database::fork_database()

View file

@ -25,7 +25,6 @@
#include <graphene/chain/genesis_state.hpp>
// these are required to serialize a genesis_state
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode
#include <graphene/chain/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {

View file

@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <memory>
#include <graphene/chain/protocol/base.hpp>
#include <graphene/chain/protocol/ext.hpp>
#include <graphene/chain/protocol/types.hpp>
@ -72,8 +73,7 @@ namespace graphene { namespace chain {
struct chain_parameters
{
/** using a smart ref breaks the circular dependency created between operations and the fee schedule */
smart_ref<fee_schedule> current_fees; ///< current schedule of fees
std::shared_ptr<fee_schedule> current_fees; ///< current schedule of fees
uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks
uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events
uint8_t maintenance_skip_slots = GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS; ///< number of block_intervals to skip at maintenance time

View file

@ -84,6 +84,10 @@ namespace graphene { namespace chain {
} } // graphene::chain
namespace fc {
template<> struct get_typename<std::shared_ptr<graphene::chain::fee_schedule>> { static const char* name() { return "shared_ptr<fee_schedule>"; } };
}
FC_REFLECT_TYPENAME( graphene::chain::fee_parameters )
FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) )

View file

@ -38,7 +38,6 @@
#include <fc/io/raw_fwd.hpp>
#include <fc/uint128.hpp>
#include <fc/static_variant.hpp>
#include <fc/smart_ref_fwd.hpp>
#include <memory>
#include <vector>
@ -89,7 +88,6 @@ namespace graphene { namespace chain {
using std::tie;
using std::make_pair;
using fc::smart_ref;
using fc::variant_object;
using fc::variant;
using fc::enum_type;

View file

@ -35,7 +35,6 @@
#include <graphene/chain/protocol/market.hpp>
#include <fc/uint128.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {
void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_operation& op)

View file

@ -32,8 +32,6 @@
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace chain {
struct proposal_operation_hardfork_visitor

View file

@ -0,0 +1,8 @@
#include <graphene/chain/protocol/chain_parameters.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {
chain_parameters::chain_parameters() {
current_fees = std::make_shared<fee_schedule>();
}
}}

View file

@ -23,17 +23,6 @@
*/
#include <algorithm>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>
namespace fc
{
// explicitly instantiate the smart_ref, gcc fails to instantiate it in some release builds
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(smart_ref<graphene::chain::fee_schedule>&&);
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(U&&);
//template graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator=(const smart_ref&);
//template smart_ref<graphene::chain::fee_schedule>::smart_ref();
//template const graphene::chain::fee_schedule& smart_ref<graphene::chain::fee_schedule>::operator*() const;
}
#include <fc/io/raw.hpp>
@ -41,10 +30,6 @@ namespace fc
namespace graphene { namespace chain {
typedef fc::smart_ref<fee_schedule> smart_fee_schedule;
static smart_fee_schedule tmp;
fee_schedule::fee_schedule()
{
}

View file

@ -23,7 +23,6 @@
*/
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/io/raw.hpp>

View file

@ -25,7 +25,6 @@
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>
#include <fc/bitutil.hpp>
#include <fc/smart_ref_impl.hpp>
#include <algorithm>
#include <fc/io/raw.hpp>

View file

@ -30,7 +30,6 @@
#include <boost/algorithm/string.hpp>
#include <fc/filesystem.hpp>
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode
#include <fc/string.hpp>
#include <fc/io/fstream.hpp>
#include <fc/io/json.hpp>

View file

@ -70,7 +70,6 @@
#include <fc/crypto/rand.hpp>
#include <fc/network/rate_limiting.hpp>
#include <fc/network/ip.hpp>
#include <fc/smart_ref_impl.hpp>
#include <graphene/net/node.hpp>
#include <graphene/net/peer_database.hpp>

View file

@ -35,7 +35,6 @@
#include <graphene/chain/transaction_evaluation_state.hpp>
#include <graphene/chain/hardfork.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/thread/thread.hpp>
namespace graphene { namespace account_history {

View file

@ -28,7 +28,6 @@
#include <graphene/utilities/key_conversion.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/thread/thread.hpp>
#include <iostream>

View file

@ -30,8 +30,6 @@
#include <fc/network/http/websocket.hpp>
#include <fc/rpc/websocket_api.hpp>
#include <fc/api.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace delayed_node {
namespace bpo = boost::program_options;

View file

@ -24,8 +24,6 @@
#include <graphene/es_objects/es_objects.hpp>
#include <fc/smart_ref_impl.hpp>
#include <curl/curl.h>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/balance_object.hpp>

View file

@ -34,7 +34,6 @@
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/thread/thread.hpp>
#include <fc/smart_ref_impl.hpp>
namespace graphene { namespace market_history {

View file

@ -30,7 +30,6 @@
#include <boost/range/algorithm_ext/insert.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/thread/thread.hpp>
#include <iostream>

View file

@ -84,7 +84,6 @@
#include <graphene/wallet/api_documentation.hpp>
#include <graphene/wallet/reflect_util.hpp>
#include <graphene/debug_witness/debug_api.hpp>
#include <fc/smart_ref_impl.hpp>
#ifndef WIN32
# include <sys/types.h>
@ -662,10 +661,10 @@ public:
return ob.template as<T>( GRAPHENE_MAX_NESTED_OBJECTS );
}
void set_operation_fees( signed_transaction& tx, const fee_schedule& s )
void set_operation_fees( signed_transaction& tx, const std::shared_ptr<fee_schedule> s )
{
for( auto& op : tx.operations )
s.set_fee(op);
s->set_fee(op);
}
variant info() const
@ -1307,8 +1306,7 @@ public:
tx.operations.push_back( account_create_op );
auto current_fees = _remote_db->get_global_properties().parameters.current_fees;
set_operation_fees( tx, current_fees );
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees );
vector<public_key_type> paying_keys = registrar_account_object.active.get_keys();
@ -3496,7 +3494,7 @@ public:
new_fees.scale = scale;
chain_parameters new_params = current_params;
new_params.current_fees = new_fees;
new_params.current_fees = std::make_shared<fee_schedule>(new_fees);
committee_member_update_global_parameters_operation update_op;
update_op.new_parameters = new_params;

View file

@ -28,7 +28,6 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <iostream>
using namespace graphene::chain;

View file

@ -30,7 +30,6 @@
#include <fc/io/fstream.hpp>
#include <fc/io/json.hpp>
#include <fc/io/stdio.hpp>
#include <fc/smart_ref_impl.hpp>
#include <graphene/app/api.hpp>
#include <graphene/chain/protocol/address.hpp>

View file

@ -55,7 +55,6 @@
#include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/sidechain_transaction_object.hpp>
#include <fc/smart_ref_impl.hpp>
#include <iostream>
using namespace graphene::chain;
@ -128,7 +127,6 @@ struct js_name<fc::array<T,N>>
template<size_t N> struct js_name<fc::array<char,N>> { static std::string name(){ return "bytes "+ fc::to_string(N); }; };
template<size_t N> struct js_name<fc::array<uint8_t,N>> { static std::string name(){ return "bytes "+ fc::to_string(N); }; };
template<typename T> struct js_name< fc::optional<T> > { static std::string name(){ return "optional " + js_name<T>::name(); } };
template<typename T> struct js_name< fc::smart_ref<T> > { static std::string name(){ return js_name<T>::name(); } };
template<> struct js_name< object_id_type > { static std::string name(){ return "object_id_type"; } };
template<typename T> struct js_name< fc::flat_set<T> > { static std::string name(){ return "set " + js_name<T>::name(); } };
template<typename T> struct js_name< std::vector<T> > { static std::string name(){ return "array " + js_name<T>::name(); } };
@ -256,14 +254,6 @@ struct serializer<std::vector<T>,false>
static void generate() {}
};
template<typename T>
struct serializer<fc::smart_ref<T>,false>
{
static void init() {
serializer<T>::init(); }
static void generate() {}
};
template<>
struct serializer<std::vector<operation>,false>
{

View file

@ -23,7 +23,6 @@
*/
#include <fc/io/json.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/variant.hpp>
#include <fc/variant_object.hpp>

View file

@ -35,7 +35,6 @@
#include <graphene/affiliate_stats/affiliate_stats_plugin.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
#include <fc/thread/thread.hpp>
#include <fc/smart_ref_impl.hpp>
#include <boost/filesystem/path.hpp>

View file

@ -26,7 +26,6 @@
#include <graphene/utilities/tempdir.hpp>
#include <fc/crypto/digest.hpp>
#include <fc/smart_ref_impl.hpp>
#include <boost/test/auto_unit_test.hpp>

View file

@ -48,7 +48,6 @@
#include <graphene/utilities/tempdir.hpp>
#include <fc/crypto/digest.hpp>
#include <fc/smart_ref_impl.hpp>
#include <exception>
#include <iostream>
@ -712,7 +711,7 @@ void database_fixture::change_fees(
new_fees.scale = new_scale;
chain_parameters new_chain_params = current_chain_params;
new_chain_params.current_fees = new_fees;
new_chain_params.current_fees = std::make_shared<fee_schedule>(new_fees);
db.modify(db.get_global_properties(), [&](global_property_object& p) {
p.parameters = new_chain_params;
@ -1039,7 +1038,7 @@ void database_fixture::enable_fees()
{
db.modify(global_property_id_type()(db), [](global_property_object& gpo)
{
gpo.parameters.current_fees = fee_schedule::get_default();
gpo.parameters.current_fees = std::make_shared<fee_schedule>(fee_schedule::get_default());
});
}

View file

@ -26,7 +26,6 @@
#include <graphene/app/application.hpp>
#include <graphene/chain/database.hpp>
#include <fc/io/json.hpp>
#include <fc/smart_ref_impl.hpp>
#include <graphene/chain/operation_history_object.hpp>

View file

@ -30,7 +30,6 @@
#include <fc/io/fstream.hpp>
#include <fc/io/json.hpp>
#include <fc/io/stdio.hpp>
#include <fc/smart_ref_impl.hpp>
#include <graphene/app/api.hpp>
#include <graphene/chain/protocol/protocol.hpp>

View file

@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#include <fc/smart_ref_impl.hpp>
#include <fc/uint128.hpp>
#include <graphene/chain/hardfork.hpp>
@ -334,7 +333,7 @@ BOOST_AUTO_TEST_CASE( cashback_test )
upgrade_to_lifetime_member(rog_id);
BOOST_TEST_MESSAGE("Enable fees");
const auto& fees = db.get_global_properties().parameters.current_fees;
const auto& fees = *db.get_global_properties().parameters.current_fees;
#define CustomRegisterActor(actor_name, registrar_name, referrer_name, referrer_rate) \
{ \
@ -346,7 +345,7 @@ BOOST_AUTO_TEST_CASE( cashback_test )
op.options.memo_key = actor_name ## _private_key.get_public_key(); \
op.active = authority(1, public_key_type(actor_name ## _private_key.get_public_key()), 1); \
op.owner = op.active; \
op.fee = fees->calculate_fee(op); \
op.fee = fees.calculate_fee(op); \
trx.operations = {op}; \
sign( trx, registrar_name ## _private_key ); \
actor_name ## _id = PUSH_TX( db, trx ).operation_results.front().get<object_id_type>(); \
@ -372,10 +371,10 @@ BOOST_AUTO_TEST_CASE( cashback_test )
CustomAuditActor( pleb ); \
}
int64_t reg_fee = fees->get< account_create_operation >().premium_fee;
int64_t xfer_fee = fees->get< transfer_operation >().fee;
int64_t upg_an_fee = fees->get< account_upgrade_operation >().membership_annual_fee;
int64_t upg_lt_fee = fees->get< account_upgrade_operation >().membership_lifetime_fee;
int64_t reg_fee = fees.get< account_create_operation >().premium_fee;
int64_t xfer_fee = fees.get< transfer_operation >().fee;
int64_t upg_an_fee = fees.get< account_upgrade_operation >().membership_annual_fee;
int64_t upg_lt_fee = fees.get< account_upgrade_operation >().membership_lifetime_fee;
// all percentages here are cut from whole pie!
uint64_t network_pct = 20 * P1;
uint64_t lt_pct = 375 * P100 / 1000;
@ -582,7 +581,7 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling )
auto accounts_per_scale = db.get_global_properties().parameters.accounts_per_fee_scale;
db.modify(global_property_id_type()(db), [](global_property_object& gpo)
{
gpo.parameters.current_fees = fee_schedule::get_default();
gpo.parameters.current_fees = std::make_shared<fee_schedule>(fee_schedule::get_default());
gpo.parameters.current_fees->get<account_create_operation>().basic_fee = 1;
});
@ -1004,7 +1003,8 @@ BOOST_AUTO_TEST_CASE( issue_429_test )
// make sure the database requires our fee to be nonzero
enable_fees();
auto fees_to_pay = db.get_global_properties().parameters.current_fees->get<asset_create_operation>();
const auto& fees = *db.get_global_properties().parameters.current_fees;
auto fees_to_pay = fees.get<asset_create_operation>();
{
signed_transaction tx;