Merge branch 'develop' into feature/nft_lottery
This commit is contained in:
commit
52be7b329f
69 changed files with 1647 additions and 1140 deletions
|
|
@ -12,7 +12,7 @@ stages:
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- rm -rf .git/modules/* ./docs ./libraries/fc
|
- rm -rf .git/modules/docs .git/modules/libraries/fc ./docs ./libraries/fc
|
||||||
- git submodule sync
|
- git submodule sync
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
- rm -rf build
|
- rm -rf build
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,34 @@ endif()
|
||||||
|
|
||||||
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
|
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
|
||||||
|
|
||||||
|
# function to help with cUrl
|
||||||
|
macro(FIND_CURL)
|
||||||
|
if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
set (OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||||
|
find_package(CURL REQUIRED)
|
||||||
|
list(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES} ${BOOST_THREAD_LIBRARY} ${CMAKE_DL_LIBS})
|
||||||
|
set (CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||||
|
else (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
|
||||||
|
find_package(CURL REQUIRED)
|
||||||
|
endif (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
|
||||||
|
|
||||||
|
if( WIN32 )
|
||||||
|
if ( MSVC )
|
||||||
|
list( APPEND CURL_LIBRARIES Wldap32 )
|
||||||
|
endif( MSVC )
|
||||||
|
|
||||||
|
if( MINGW )
|
||||||
|
# MinGW requires a specific order of included libraries ( CURL before ZLib )
|
||||||
|
find_package( ZLIB REQUIRED )
|
||||||
|
list( APPEND CURL_LIBRARIES ${ZLIB_LIBRARY} pthread )
|
||||||
|
endif( MINGW )
|
||||||
|
|
||||||
|
list( APPEND CURL_LIBRARIES ${PLATFORM_SPECIFIC_LIBS} )
|
||||||
|
endif( WIN32 )
|
||||||
|
endmacro()
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
|
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
|
||||||
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis.json" CACHE PATH "location of the genesis.json to embed in the executable" )
|
||||||
|
|
||||||
|
|
@ -128,7 +156,7 @@ else( WIN32 ) # Apple AND Linux
|
||||||
endif( APPLE )
|
endif( APPLE )
|
||||||
|
|
||||||
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
|
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
|
||||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp -Wno-parentheses -Wno-terminate -Wno-invalid-offsetof -Wno-sign-compare" )
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
|
||||||
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
|
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
|
||||||
if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 )
|
if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 )
|
||||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ namespace graphene { namespace app {
|
||||||
void network_broadcast_api::broadcast_transaction(const signed_transaction& trx)
|
void network_broadcast_api::broadcast_transaction(const signed_transaction& trx)
|
||||||
{
|
{
|
||||||
trx.validate();
|
trx.validate();
|
||||||
_app.chain_database()->check_tansaction_for_duplicated_operations(trx);
|
_app.chain_database()->check_transaction_for_duplicated_operations(trx);
|
||||||
_app.chain_database()->push_transaction(trx);
|
_app.chain_database()->push_transaction(trx);
|
||||||
if( _app.p2p_node() != nullptr )
|
if( _app.p2p_node() != nullptr )
|
||||||
_app.p2p_node()->broadcast_transaction(trx);
|
_app.p2p_node()->broadcast_transaction(trx);
|
||||||
|
|
@ -189,7 +189,7 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
|
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
|
||||||
{
|
{
|
||||||
_app.chain_database()->check_tansaction_for_duplicated_operations(trx);
|
_app.chain_database()->check_transaction_for_duplicated_operations(trx);
|
||||||
|
|
||||||
fc::promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
|
fc::promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
|
||||||
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
|
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
|
||||||
|
|
|
||||||
|
|
@ -160,10 +160,12 @@ namespace detail {
|
||||||
{
|
{
|
||||||
// t.me/peerplays #seednodes
|
// t.me/peerplays #seednodes
|
||||||
vector<string> seeds = {
|
vector<string> seeds = {
|
||||||
"ppy-beatrice-seed.blckchnd.com:6666",
|
"pts.blockveritas.co:6666",
|
||||||
"159.69.223.206:7777",
|
"seed-beatrice01.eifos.org:7777",
|
||||||
"51.38.237.243:9666",
|
"seed-testnet.ppy.alex-pu.info:7777",
|
||||||
"pbsa-beatrice.blockchainprojectsbv.com:9195"
|
"seed.ppy-beatrice.blckchnd.com:6666",
|
||||||
|
"seed.testnet.peerblock.trade:6666",
|
||||||
|
"testnet-ppyapi.spacemx.tech:9777"
|
||||||
};
|
};
|
||||||
|
|
||||||
for( const string& endpoint_string : seeds )
|
for( const string& endpoint_string : seeds )
|
||||||
|
|
@ -378,7 +380,6 @@ namespace detail {
|
||||||
_chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as<bool>() );
|
_chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as<bool>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool replay = false;
|
|
||||||
std::string replay_reason = "reason not provided";
|
std::string replay_reason = "reason not provided";
|
||||||
|
|
||||||
if( _options->count("replay-blockchain") )
|
if( _options->count("replay-blockchain") )
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
||||||
|
|
||||||
// Keys
|
// Keys
|
||||||
vector<vector<account_id_type>> get_key_references( vector<public_key_type> key )const;
|
vector<vector<account_id_type>> get_key_references( vector<public_key_type> key )const;
|
||||||
bool is_public_key_registered(string public_key) const;
|
bool is_public_key_registered(string public_key) const;
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
account_id_type get_account_id_from_string(const std::string& name_or_id)const;
|
account_id_type get_account_id_from_string(const std::string& name_or_id)const;
|
||||||
|
|
@ -2112,7 +2112,7 @@ vector<variant> database_api_impl::lookup_vote_ids( const vector<vote_id_type>&
|
||||||
{
|
{
|
||||||
auto itr = son_idx.find( id );
|
auto itr = son_idx.find( id );
|
||||||
if( itr != son_idx.end() )
|
if( itr != son_idx.end() )
|
||||||
result.emplace_back( variant( *itr, 1 ) );
|
result.emplace_back( variant( *itr, 5 ) );
|
||||||
else
|
else
|
||||||
result.emplace_back( variant() );
|
result.emplace_back( variant() );
|
||||||
break;
|
break;
|
||||||
|
|
@ -2572,18 +2572,8 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
|
||||||
|
|
||||||
share_type total_amount;
|
share_type total_amount;
|
||||||
auto balance_type = vesting_balance_type::gpos;
|
auto balance_type = vesting_balance_type::gpos;
|
||||||
#ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX
|
|
||||||
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
|
|
||||||
auto vesting_balances_begin =
|
|
||||||
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(asset_id_type(), balance_type));
|
|
||||||
auto vesting_balances_end =
|
|
||||||
vesting_index.indices().get<by_asset_balance>().upper_bound(boost::make_tuple(asset_id_type(), balance_type, share_type()));
|
|
||||||
|
|
||||||
for (const vesting_balance_object& vesting_balance_obj : boost::make_iterator_range(vesting_balances_begin, vesting_balances_end))
|
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
|
||||||
{
|
|
||||||
total_amount += vesting_balance_obj.balance.amount;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
const vesting_balance_index& vesting_index = _db.get_index_type<vesting_balance_index>();
|
const vesting_balance_index& vesting_index = _db.get_index_type<vesting_balance_index>();
|
||||||
const auto& vesting_balances = vesting_index.indices().get<by_id>();
|
const auto& vesting_balances = vesting_index.indices().get<by_id>();
|
||||||
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
|
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
|
||||||
|
|
@ -2593,7 +2583,6 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
|
||||||
total_amount += vesting_balance_obj.balance.amount;
|
total_amount += vesting_balance_obj.balance.amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
vector<vesting_balance_object> account_vbos;
|
vector<vesting_balance_object> account_vbos;
|
||||||
const time_point_sec now = _db.head_block_time();
|
const time_point_sec now = _db.head_block_time();
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,5 @@ FC_REFLECT( graphene::app::full_account,
|
||||||
(proposals)
|
(proposals)
|
||||||
(assets)
|
(assets)
|
||||||
(withdraws)
|
(withdraws)
|
||||||
(proposals)
|
|
||||||
(pending_dividend_payments)
|
(pending_dividend_payments)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,6 @@ void_result asset_update_dividend_evaluator::do_apply( const asset_update_divide
|
||||||
obj.referrer = op.issuer;
|
obj.referrer = op.issuer;
|
||||||
obj.lifetime_referrer = op.issuer(db()).lifetime_referrer;
|
obj.lifetime_referrer = op.issuer(db()).lifetime_referrer;
|
||||||
|
|
||||||
auto& params = db().get_global_properties().parameters;
|
|
||||||
obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
|
obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
|
||||||
obj.lifetime_referrer_fee_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
obj.lifetime_referrer_fee_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
||||||
obj.referrer_rewards_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
obj.referrer_rewards_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ map< account_id_type, vector< uint16_t > > asset_object::distribute_winners_part
|
||||||
*t += percents_to_distribute / holders.size();
|
*t += percents_to_distribute / holders.size();
|
||||||
}
|
}
|
||||||
auto sweeps_distribution_percentage = db.get_global_properties().parameters.sweeps_distribution_percentage();
|
auto sweeps_distribution_percentage = db.get_global_properties().parameters.sweeps_distribution_percentage();
|
||||||
for( int c = 0; c < winner_numbers.size(); ++c ) {
|
for( size_t c = 0; c < winner_numbers.size(); ++c ) {
|
||||||
auto winner_num = winner_numbers[c];
|
auto winner_num = winner_numbers[c];
|
||||||
lottery_reward_operation reward_op;
|
lottery_reward_operation reward_op;
|
||||||
reward_op.lottery = get_id();
|
reward_op.lottery = get_id();
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,10 @@ void database::adjust_sweeps_vesting_balance(account_id_type account, int64_t de
|
||||||
b.balance = delta;
|
b.balance = delta;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if( delta < 0 )
|
if( delta < 0 ) {
|
||||||
FC_ASSERT( itr->get_balance() >= -delta, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account)("b",itr->get_balance())("r",-delta));
|
uint64_t delta_uint64 = -delta;
|
||||||
|
FC_ASSERT( itr->get_balance() >= delta_uint64, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account)("b",itr->get_balance())("r",-delta));
|
||||||
|
}
|
||||||
modify(*itr, [&delta,&asset_id,this](sweeps_vesting_balance_object& b) {
|
modify(*itr, [&delta,&asset_id,this](sweeps_vesting_balance_object& b) {
|
||||||
b.adjust_balance( asset( delta, asset_id ) );
|
b.adjust_balance( asset( delta, asset_id ) );
|
||||||
b.last_claim_date = head_block_time();
|
b.last_claim_date = head_block_time();
|
||||||
|
|
|
||||||
|
|
@ -303,8 +303,6 @@ void database::settle_betting_market_group(const betting_market_group_object& be
|
||||||
remove(betting_market);
|
remove(betting_market);
|
||||||
}
|
}
|
||||||
|
|
||||||
const event_object& event = betting_market_group.event_id(*this);
|
|
||||||
|
|
||||||
fc_dlog(fc::logger::get("betting"), "removing betting market group ${id}", ("id", betting_market_group.id));
|
fc_dlog(fc::logger::get("betting"), "removing betting market group ${id}", ("id", betting_market_group.id));
|
||||||
remove(betting_market_group);
|
remove(betting_market_group);
|
||||||
|
|
||||||
|
|
@ -537,11 +535,9 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker
|
||||||
// because we matched at the maker's odds and not the taker's odds, the remaining amount to match
|
// because we matched at the maker's odds and not the taker's odds, the remaining amount to match
|
||||||
// may not be an even multiple of the taker's odds; round it down.
|
// may not be an even multiple of the taker's odds; round it down.
|
||||||
share_type taker_remaining_factor = unrounded_taker_remaining_amount_to_match / takers_odds_maker_odds_ratio;
|
share_type taker_remaining_factor = unrounded_taker_remaining_amount_to_match / takers_odds_maker_odds_ratio;
|
||||||
share_type taker_remaining_maker_amount_to_match = taker_remaining_factor * takers_odds_maker_odds_ratio;
|
|
||||||
share_type taker_remaining_bet_amount = taker_remaining_factor * takers_odds_taker_odds_ratio;
|
share_type taker_remaining_bet_amount = taker_remaining_factor * takers_odds_taker_odds_ratio;
|
||||||
|
|
||||||
taker_refund_amount = taker_bet.amount_to_bet.amount - taker_amount_to_match - taker_remaining_bet_amount;
|
taker_refund_amount = taker_bet.amount_to_bet.amount - taker_amount_to_match - taker_remaining_bet_amount;
|
||||||
//idump((taker_remaining_factor)(taker_remaining_maker_amount_to_match)(taker_remaining_bet_amount)(taker_refund_amount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taker_refund_amount > share_type())
|
if (taker_refund_amount > share_type())
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ std::vector<block_id_type> database::get_block_ids_on_fork(block_id_type head_of
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void database::check_tansaction_for_duplicated_operations(const signed_transaction& trx)
|
void database::check_transaction_for_duplicated_operations(const signed_transaction& trx)
|
||||||
{
|
{
|
||||||
const auto& proposal_index = get_index<proposal_object>();
|
const auto& proposal_index = get_index<proposal_object>();
|
||||||
std::set<fc::sha256> existed_operations_digests;
|
std::set<fc::sha256> existed_operations_digests;
|
||||||
|
|
|
||||||
|
|
@ -948,7 +948,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
|
|
||||||
const auto& idx = get_index_type<asset_index>().indices().get<by_symbol>();
|
const auto& idx = get_index_type<asset_index>().indices().get<by_symbol>();
|
||||||
auto it = idx.begin();
|
auto it = idx.begin();
|
||||||
bool has_imbalanced_assets = false;
|
|
||||||
|
|
||||||
while( it != idx.end() )
|
while( it != idx.end() )
|
||||||
{
|
{
|
||||||
|
|
@ -960,7 +959,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
FC_ASSERT( debt_itr != total_debts.end() );
|
FC_ASSERT( debt_itr != total_debts.end() );
|
||||||
if( supply_itr->second != debt_itr->second )
|
if( supply_itr->second != debt_itr->second )
|
||||||
{
|
{
|
||||||
has_imbalanced_assets = true;
|
|
||||||
elog( "Genesis for asset ${aname} is not balanced\n"
|
elog( "Genesis for asset ${aname} is not balanced\n"
|
||||||
" Debt is ${debt}\n"
|
" Debt is ${debt}\n"
|
||||||
" Supply is ${supply}\n",
|
" Supply is ${supply}\n",
|
||||||
|
|
@ -972,10 +970,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
// @romek
|
|
||||||
#if 0
|
|
||||||
FC_ASSERT( !has_imbalanced_assets );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Save tallied supplies
|
// Save tallied supplies
|
||||||
for( const auto& item : total_supplies )
|
for( const auto& item : total_supplies )
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@
|
||||||
#include <graphene/chain/witness_schedule_object.hpp>
|
#include <graphene/chain/witness_schedule_object.hpp>
|
||||||
#include <graphene/chain/worker_object.hpp>
|
#include <graphene/chain/worker_object.hpp>
|
||||||
|
|
||||||
#define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed
|
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
template<class Index>
|
template<class Index>
|
||||||
|
|
@ -1192,7 +1190,6 @@ uint32_t database::get_gpos_current_subperiod()
|
||||||
const auto period_start = fc::time_point_sec(gpo.parameters.gpos_period_start());
|
const auto period_start = fc::time_point_sec(gpo.parameters.gpos_period_start());
|
||||||
|
|
||||||
// variables needed
|
// variables needed
|
||||||
const fc::time_point_sec period_end = period_start + vesting_period;
|
|
||||||
const auto number_of_subperiods = vesting_period / vesting_subperiod;
|
const auto number_of_subperiods = vesting_period / vesting_subperiod;
|
||||||
const auto now = this->head_block_time();
|
const auto now = this->head_block_time();
|
||||||
auto seconds_since_period_start = now.sec_since_epoch() - period_start.sec_since_epoch();
|
auto seconds_since_period_start = now.sec_since_epoch() - period_start.sec_since_epoch();
|
||||||
|
|
@ -1385,7 +1382,6 @@ void schedule_pending_dividend_balances(database& db,
|
||||||
|
|
||||||
uint32_t holder_account_count = 0;
|
uint32_t holder_account_count = 0;
|
||||||
|
|
||||||
#ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX
|
|
||||||
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
|
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
|
||||||
auto vesting_balances_begin =
|
auto vesting_balances_begin =
|
||||||
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(dividend_holder_asset_obj.id, balance_type));
|
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(dividend_holder_asset_obj.id, balance_type));
|
||||||
|
|
@ -1400,22 +1396,6 @@ void schedule_pending_dividend_balances(database& db,
|
||||||
("owner", vesting_balance_obj.owner(db).name)
|
("owner", vesting_balance_obj.owner(db).name)
|
||||||
("amount", vesting_balance_obj.balance.amount));
|
("amount", vesting_balance_obj.balance.amount));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
// get only once a collection of accounts that hold nonzero vesting balances of the dividend asset
|
|
||||||
const auto& vesting_balances = vesting_index.indices().get<by_id>();
|
|
||||||
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
|
|
||||||
{
|
|
||||||
if (vesting_balance_obj.balance.asset_id == dividend_holder_asset_obj.id && vesting_balance_obj.balance.amount &&
|
|
||||||
vesting_balance_object.balance_type == balance_type)
|
|
||||||
{
|
|
||||||
vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount;
|
|
||||||
++gpos_holder_account_count;
|
|
||||||
dlog("Vesting balance for account: ${owner}, amount: ${amount}",
|
|
||||||
("owner", vesting_balance_obj.owner(db).name)
|
|
||||||
("amount", vesting_balance_obj.balance.amount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto current_distribution_account_balance_iter = current_distribution_account_balance_range.begin();
|
auto current_distribution_account_balance_iter = current_distribution_account_balance_range.begin();
|
||||||
if(db.head_block_time() < HARDFORK_GPOS_TIME)
|
if(db.head_block_time() < HARDFORK_GPOS_TIME)
|
||||||
|
|
@ -1869,7 +1849,6 @@ void process_dividend_assets(database& db)
|
||||||
{
|
{
|
||||||
// if there was a previous payout, make our next payment one interval
|
// if there was a previous payout, make our next payment one interval
|
||||||
uint32_t current_time_sec = current_head_block_time.sec_since_epoch();
|
uint32_t current_time_sec = current_head_block_time.sec_since_epoch();
|
||||||
fc::time_point_sec reference_time = *dividend_data_obj.last_scheduled_payout_time;
|
|
||||||
uint32_t next_possible_time_sec = dividend_data_obj.last_scheduled_payout_time->sec_since_epoch();
|
uint32_t next_possible_time_sec = dividend_data_obj.last_scheduled_payout_time->sec_since_epoch();
|
||||||
do
|
do
|
||||||
next_possible_time_sec += *dividend_data_obj.options.payout_interval;
|
next_possible_time_sec += *dividend_data_obj.options.payout_interval;
|
||||||
|
|
@ -1990,7 +1969,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
||||||
balance_type = vesting_balance_type::gpos;
|
balance_type = vesting_balance_type::gpos;
|
||||||
|
|
||||||
const vesting_balance_index& vesting_index = d.get_index_type<vesting_balance_index>();
|
const vesting_balance_index& vesting_index = d.get_index_type<vesting_balance_index>();
|
||||||
#ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX
|
|
||||||
auto vesting_balances_begin =
|
auto vesting_balances_begin =
|
||||||
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(asset_id_type(), balance_type));
|
vesting_index.indices().get<by_asset_balance>().lower_bound(boost::make_tuple(asset_id_type(), balance_type));
|
||||||
auto vesting_balances_end =
|
auto vesting_balances_end =
|
||||||
|
|
@ -2002,19 +1981,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
||||||
("owner", vesting_balance_obj.owner(d).name)
|
("owner", vesting_balance_obj.owner(d).name)
|
||||||
("amount", vesting_balance_obj.balance.amount));
|
("amount", vesting_balance_obj.balance.amount));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
const auto& vesting_balances = vesting_index.indices().get<by_id>();
|
|
||||||
for (const vesting_balance_object& vesting_balance_obj : vesting_balances)
|
|
||||||
{
|
|
||||||
if (vesting_balance_obj.balance.asset_id == asset_id_type() && vesting_balance_obj.balance.amount && vesting_balance_obj.balance_type == balance_type)
|
|
||||||
{
|
|
||||||
vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount;
|
|
||||||
dlog("Vesting balance for account: ${owner}, amount: ${amount}",
|
|
||||||
("owner", vesting_balance_obj.owner(d).name)
|
|
||||||
("amount", vesting_balance_obj.balance.amount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()( const account_object& stake_account, const account_statistics_object& stats )
|
void operator()( const account_object& stake_account, const account_statistics_object& stats )
|
||||||
|
|
|
||||||
|
|
@ -543,6 +543,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
} case sidechain_transaction_object_type:{
|
} case sidechain_transaction_object_type:{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( obj->id.space() == implementation_ids )
|
else if( obj->id.space() == implementation_ids )
|
||||||
|
|
@ -598,6 +601,8 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
case impl_fba_accumulator_object_type:
|
case impl_fba_accumulator_object_type:
|
||||||
break;
|
break;
|
||||||
case impl_nft_lottery_balance_object_type:
|
case impl_nft_lottery_balance_object_type:
|
||||||
|
break
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ 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 )
|
||||||
{
|
{
|
||||||
const dynamic_global_property_object& _dgp = get_dynamic_global_properties();
|
const dynamic_global_property_object& _dgp = get_dynamic_global_properties();
|
||||||
const global_property_object& gpo = get_global_properties();
|
|
||||||
|
|
||||||
// dynamic global properties updating
|
// dynamic global properties updating
|
||||||
modify( _dgp, [&b,this,missed_blocks]( dynamic_global_property_object& dgp ){
|
modify( _dgp, [&b,this,missed_blocks]( dynamic_global_property_object& dgp ){
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// SON HARDFORK Wednesday, October 28, 2020 0:00:00 GMT
|
// SON HARDFORK Wednesday, October 28, 2020 0:00:00 GMT
|
||||||
#ifndef HARDFORK_SON_TIME
|
#ifndef HARDFORK_SON_TIME
|
||||||
#include <ctime>
|
|
||||||
#define HARDFORK_SON_TIME (fc::time_point_sec( 1603843200 ))
|
#define HARDFORK_SON_TIME (fc::time_point_sec( 1603843200 ))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -718,8 +718,8 @@ inline Stream& operator>>( Stream& s, betting_market_group_object& betting_marke
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) )
|
FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) )
|
||||||
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description) )
|
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description)(event_id)(rules_id)(asset_id)(total_matched_bets_amount)(never_in_play)(delay_before_settling)(settling_time) )
|
||||||
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id) )
|
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition)(resolution) )
|
||||||
FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) )
|
FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) )
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) )
|
FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) )
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
|
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
|
||||||
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
|
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
|
||||||
|
|
||||||
#define GRAPHENE_CURRENT_DB_VERSION "PPY2.3"
|
#define GRAPHENE_CURRENT_DB_VERSION "PPY2.4"
|
||||||
|
|
||||||
#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
|
#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ namespace graphene { namespace chain {
|
||||||
const flat_map<uint32_t,block_id_type> get_checkpoints()const { return _checkpoints; }
|
const flat_map<uint32_t,block_id_type> get_checkpoints()const { return _checkpoints; }
|
||||||
bool before_last_checkpoint()const;
|
bool before_last_checkpoint()const;
|
||||||
|
|
||||||
void check_tansaction_for_duplicated_operations(const signed_transaction& trx);
|
void check_transaction_for_duplicated_operations(const signed_transaction& trx);
|
||||||
|
|
||||||
bool push_block( const signed_block& b, uint32_t skip = skip_nothing );
|
bool push_block( const signed_block& b, uint32_t skip = skip_nothing );
|
||||||
processed_transaction push_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
|
processed_transaction push_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
|
||||||
|
|
|
||||||
|
|
@ -158,5 +158,6 @@ typedef generic_index<event_object, event_object_multi_index_type> event_object_
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
FC_REFLECT(graphene::chain::event_object, (name))
|
FC_REFLECT(graphene::chain::event_object, (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class global_betting_statistics_object : public graphene::db::abstract_object< g
|
||||||
static const uint8_t space_id = implementation_ids;
|
static const uint8_t space_id = implementation_ids;
|
||||||
static const uint8_t type_id = impl_global_betting_statistics_object_type;
|
static const uint8_t type_id = impl_global_betting_statistics_object_type;
|
||||||
|
|
||||||
uint32_t number_of_active_events;
|
uint32_t number_of_active_events = 0;
|
||||||
map<asset_id_type, share_type> total_amount_staked;
|
map<asset_id_type, share_type> total_amount_staked;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -481,13 +481,13 @@ FC_REFLECT( graphene::chain::bet_place_operation,
|
||||||
(fee)(bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(extensions) )
|
(fee)(bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(extensions) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::bet_matched_operation::fee_parameters_type, )
|
FC_REFLECT( graphene::chain::bet_matched_operation::fee_parameters_type, )
|
||||||
FC_REFLECT( graphene::chain::bet_matched_operation, (bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) )
|
FC_REFLECT( graphene::chain::bet_matched_operation, (fee)(bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::bet_cancel_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::bet_cancel_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT( graphene::chain::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) )
|
FC_REFLECT( graphene::chain::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::bet_canceled_operation::fee_parameters_type, )
|
FC_REFLECT( graphene::chain::bet_canceled_operation::fee_parameters_type, )
|
||||||
FC_REFLECT( graphene::chain::bet_canceled_operation, (bettor_id)(bet_id)(stake_returned) )
|
FC_REFLECT( graphene::chain::bet_canceled_operation, (fee)(bettor_id)(bet_id)(stake_returned) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::bet_adjusted_operation::fee_parameters_type, )
|
FC_REFLECT( graphene::chain::bet_adjusted_operation::fee_parameters_type, )
|
||||||
FC_REFLECT( graphene::chain::bet_adjusted_operation, (bettor_id)(bet_id)(stake_returned) )
|
FC_REFLECT( graphene::chain::bet_adjusted_operation, (fee) (bettor_id)(bet_id)(stake_returned) )
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace graphene { namespace chain {
|
||||||
static const uint8_t space_id = protocol_ids;
|
static const uint8_t space_id = protocol_ids;
|
||||||
static const uint8_t type_id = sidechain_transaction_object_type;
|
static const uint8_t type_id = sidechain_transaction_object_type;
|
||||||
|
|
||||||
sidechain_type sidechain;
|
sidechain_type sidechain = sidechain_type::unknown;
|
||||||
object_id_type object_id;
|
object_id_type object_id;
|
||||||
std::string transaction;
|
std::string transaction;
|
||||||
std::vector<son_info> signers;
|
std::vector<son_info> signers;
|
||||||
|
|
@ -37,7 +37,7 @@ namespace graphene { namespace chain {
|
||||||
uint32_t current_weight = 0;
|
uint32_t current_weight = 0;
|
||||||
uint32_t threshold = 0;
|
uint32_t threshold = 0;
|
||||||
|
|
||||||
sidechain_transaction_status status;
|
sidechain_transaction_status status = sidechain_transaction_status::invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct by_object_id;
|
struct by_object_id;
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,17 @@ namespace graphene { namespace chain {
|
||||||
FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) )
|
FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) )
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
|
||||||
(son_account)(vote_id)(total_votes)(url)(deposit)(signing_key)(pay_vb)(statistics)(status)(sidechain_public_keys) )
|
(son_account)
|
||||||
|
(vote_id)
|
||||||
|
(total_votes)
|
||||||
|
(url)
|
||||||
|
(deposit)
|
||||||
|
(signing_key)
|
||||||
|
(pay_vb)
|
||||||
|
(statistics)
|
||||||
|
(status)
|
||||||
|
(sidechain_public_keys)
|
||||||
|
)
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
|
FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
|
||||||
(graphene::db::object),
|
(graphene::db::object),
|
||||||
|
|
@ -131,3 +141,6 @@ FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
|
||||||
(total_sidechain_txs_reported)
|
(total_sidechain_txs_reported)
|
||||||
(sidechain_txs_reported)
|
(sidechain_txs_reported)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::son_object )
|
||||||
|
GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::son_statistics_object )
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,20 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
struct by_account;
|
struct by_account;
|
||||||
struct by_asset_balance;
|
struct by_asset_balance;
|
||||||
|
|
||||||
|
struct by_asset_balance_helper_asset_id {
|
||||||
|
typedef asset_id_type result_type;
|
||||||
|
result_type operator()(const vesting_balance_object& vbo) const {
|
||||||
|
return vbo.balance.asset_id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct by_asset_balance_helper_asset_amount {
|
||||||
|
typedef share_type result_type;
|
||||||
|
result_type operator()(const vesting_balance_object& vbo) const {
|
||||||
|
return vbo.balance.amount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef multi_index_container<
|
typedef multi_index_container<
|
||||||
vesting_balance_object,
|
vesting_balance_object,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
|
|
@ -210,11 +224,9 @@ namespace graphene { namespace chain {
|
||||||
ordered_non_unique< tag<by_asset_balance>,
|
ordered_non_unique< tag<by_asset_balance>,
|
||||||
composite_key<
|
composite_key<
|
||||||
vesting_balance_object,
|
vesting_balance_object,
|
||||||
member_offset<vesting_balance_object, asset_id_type, (size_t) (offsetof(vesting_balance_object,balance) + offsetof(asset,asset_id))>,
|
by_asset_balance_helper_asset_id,
|
||||||
member<vesting_balance_object, vesting_balance_type, &vesting_balance_object::balance_type>,
|
member<vesting_balance_object, vesting_balance_type, &vesting_balance_object::balance_type>,
|
||||||
member_offset<vesting_balance_object, share_type, (size_t) (offsetof(vesting_balance_object,balance) + offsetof(asset,amount))>
|
by_asset_balance_helper_asset_amount
|
||||||
//member<vesting_balance_object, account_id_type, &vesting_balance_object::owner>
|
|
||||||
//member_offset<vesting_balance_object, account_id_type, (size_t) (offsetof(vesting_balance_object,owner))>
|
|
||||||
>,
|
>,
|
||||||
composite_key_compare<
|
composite_key_compare<
|
||||||
std::less< asset_id_type >,
|
std::less< asset_id_type >,
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,18 @@ struct proposal_operation_hardfork_visitor
|
||||||
FC_ASSERT( !aco.extensions.value.affiliate_distributions.valid(), "Affiliate reward distributions not allowed yet" );
|
FC_ASSERT( !aco.extensions.value.affiliate_distributions.valid(), "Affiliate reward distributions not allowed yet" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator()(const sport_create_operation &v) const {
|
||||||
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "sport_create_operation not allowed yet!" );
|
||||||
|
}
|
||||||
|
|
||||||
void operator()(const sport_update_operation &v) const {
|
void operator()(const sport_update_operation &v) const {
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "sport_update_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "sport_update_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator()(const sport_delete_operation &v) const {
|
||||||
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "sport_delete_operation not allowed yet!" );
|
||||||
|
}
|
||||||
|
|
||||||
void operator()(const event_group_create_operation &v) const {
|
void operator()(const event_group_create_operation &v) const {
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_group_create_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_group_create_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
@ -74,6 +82,10 @@ struct proposal_operation_hardfork_visitor
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_group_update_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_group_update_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator()(const event_group_delete_operation &v) const {
|
||||||
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_group_delete_operation not allowed yet!" );
|
||||||
|
}
|
||||||
|
|
||||||
void operator()(const event_create_operation &v) const {
|
void operator()(const event_create_operation &v) const {
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_create_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_create_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +123,7 @@ struct proposal_operation_hardfork_visitor
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const bet_cancel_operation &v) const {
|
void operator()(const bet_cancel_operation &v) const {
|
||||||
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "betting_market_group_resolve_operation not allowed yet!" );
|
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "bet_cancel_operation not allowed yet!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const betting_market_group_update_operation &v) const {
|
void operator()(const betting_market_group_update_operation &v) const {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include <graphene/chain/global_property_object.hpp>
|
#include <graphene/chain/global_property_object.hpp>
|
||||||
#include <graphene/chain/market_object.hpp>
|
#include <graphene/chain/market_object.hpp>
|
||||||
#include <graphene/chain/operation_history_object.hpp>
|
#include <graphene/chain/operation_history_object.hpp>
|
||||||
|
#include <graphene/chain/son_object.hpp>
|
||||||
#include <graphene/chain/special_authority_object.hpp>
|
#include <graphene/chain/special_authority_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_object.hpp>
|
||||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
|
|
@ -62,6 +63,8 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::dynamic_global
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_property_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_property_object )
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::operation_history_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::operation_history_object )
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transaction_history_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transaction_history_object )
|
||||||
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::son_object )
|
||||||
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::son_statistics_object )
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::special_authority_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::special_authority_object )
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_object )
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_object )
|
||||||
|
|
|
||||||
|
|
@ -605,8 +605,9 @@ namespace graphene { namespace chain {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// We shouldn't be here if the final match is complete
|
// We shouldn't be here if the final match is complete
|
||||||
assert(last_complete_round != num_rounds - 1);
|
uint32_t last_complete_round_uint32 = last_complete_round;
|
||||||
if (last_complete_round == num_rounds - 1)
|
assert(last_complete_round_uint32 != num_rounds - 1);
|
||||||
|
if (last_complete_round_uint32 == num_rounds - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (first_incomplete_match_was_waiting)
|
if (first_incomplete_match_was_waiting)
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,7 @@ namespace graphene { namespace db {
|
||||||
{
|
{
|
||||||
mv._apply_undo = false;
|
mv._apply_undo = false;
|
||||||
}
|
}
|
||||||
~session() {
|
~session();
|
||||||
try {
|
|
||||||
if( _apply_undo ) _db.undo();
|
|
||||||
}
|
|
||||||
catch ( const fc::exception& e )
|
|
||||||
{
|
|
||||||
elog( "${e}", ("e",e.to_detail_string() ) );
|
|
||||||
throw; // maybe crash..
|
|
||||||
}
|
|
||||||
if( _disable_on_exit ) _db.disable();
|
|
||||||
}
|
|
||||||
void commit() { _apply_undo = false; _db.commit(); }
|
void commit() { _apply_undo = false; _db.commit(); }
|
||||||
void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; }
|
void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; }
|
||||||
void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; }
|
void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; }
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,18 @@ namespace graphene { namespace db {
|
||||||
void undo_database::enable() { _disabled = false; }
|
void undo_database::enable() { _disabled = false; }
|
||||||
void undo_database::disable() { _disabled = true; }
|
void undo_database::disable() { _disabled = true; }
|
||||||
|
|
||||||
|
undo_database::session::~session() {
|
||||||
|
try {
|
||||||
|
if( _apply_undo ) _db.undo();
|
||||||
|
}
|
||||||
|
catch ( const fc::exception& e )
|
||||||
|
{
|
||||||
|
elog( "${e}", ("e",e.to_detail_string() ) );
|
||||||
|
std::terminate();
|
||||||
|
}
|
||||||
|
if( _disable_on_exit ) _db.disable();
|
||||||
|
}
|
||||||
|
|
||||||
undo_database::session undo_database::start_undo_session( bool force_enable )
|
undo_database::session undo_database::start_undo_session( bool force_enable )
|
||||||
{
|
{
|
||||||
if( _disabled && !force_enable ) return session(*this);
|
if( _disabled && !force_enable ) return session(*this);
|
||||||
|
|
|
||||||
|
|
@ -2375,6 +2375,7 @@ namespace graphene { namespace net { namespace detail {
|
||||||
VERIFY_CORRECT_THREAD();
|
VERIFY_CORRECT_THREAD();
|
||||||
item_hash_t reference_point = peer->last_block_delegate_has_seen;
|
item_hash_t reference_point = peer->last_block_delegate_has_seen;
|
||||||
uint32_t reference_point_block_num = _delegate->get_block_number(peer->last_block_delegate_has_seen);
|
uint32_t reference_point_block_num = _delegate->get_block_number(peer->last_block_delegate_has_seen);
|
||||||
|
(void)reference_point_block_num;
|
||||||
|
|
||||||
// when we call _delegate->get_blockchain_synopsis(), we may yield and there's a
|
// when we call _delegate->get_blockchain_synopsis(), we may yield and there's a
|
||||||
// chance this peer's state will change before we get control back. Save off
|
// chance this peer's state will change before we get control back. Save off
|
||||||
|
|
@ -3414,6 +3415,7 @@ namespace graphene { namespace net { namespace detail {
|
||||||
for (const item_hash_t& transaction_message_hash : contained_transaction_message_ids)
|
for (const item_hash_t& transaction_message_hash : contained_transaction_message_ids)
|
||||||
{
|
{
|
||||||
size_t items_erased = _items_to_fetch.get<item_id_index>().erase(item_id(trx_message_type, transaction_message_hash));
|
size_t items_erased = _items_to_fetch.get<item_id_index>().erase(item_id(trx_message_type, transaction_message_hash));
|
||||||
|
(void)items_erased;
|
||||||
// there are two ways we could behave here: we could either act as if we received
|
// there are two ways we could behave here: we could either act as if we received
|
||||||
// the transaction outside the block and offer it to our peers, or we could just
|
// the transaction outside the block and offer it to our peers, or we could just
|
||||||
// forget about it (we would still advertise this block to our peers so they should
|
// forget about it (we would still advertise this block to our peers so they should
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,21 @@ add_library( graphene_elasticsearch
|
||||||
elasticsearch_plugin.cpp
|
elasticsearch_plugin.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries( graphene_elasticsearch PRIVATE graphene_plugin curl )
|
find_curl()
|
||||||
target_include_directories( graphene_elasticsearch
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
|
||||||
|
|
||||||
|
include_directories(${CURL_INCLUDE_DIRS})
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
set_source_files_properties(elasticsearch_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
if(CURL_STATICLIB)
|
||||||
|
SET_TARGET_PROPERTIES(graphene_elasticsearch PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||||
|
endif(CURL_STATICLIB)
|
||||||
|
target_link_libraries( graphene_elasticsearch PRIVATE graphene_plugin ${CURL_LIBRARIES} )
|
||||||
|
target_include_directories( graphene_elasticsearch
|
||||||
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
|
PUBLIC "${CURL_INCLUDE_DIR}" )
|
||||||
|
|
||||||
|
|
||||||
install( TARGETS
|
install( TARGETS
|
||||||
graphene_elasticsearch
|
graphene_elasticsearch
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ class elasticsearch_plugin_impl
|
||||||
bool _elasticsearch_visitor = false;
|
bool _elasticsearch_visitor = false;
|
||||||
std::string _elasticsearch_basic_auth = "";
|
std::string _elasticsearch_basic_auth = "";
|
||||||
std::string _elasticsearch_index_prefix = "peerplays-";
|
std::string _elasticsearch_index_prefix = "peerplays-";
|
||||||
bool _elasticsearch_operation_object = false;
|
bool _elasticsearch_operation_object = true;
|
||||||
uint32_t _elasticsearch_start_es_after_block = 0;
|
uint32_t _elasticsearch_start_es_after_block = 0;
|
||||||
bool _elasticsearch_operation_string = true;
|
bool _elasticsearch_operation_string = false;
|
||||||
mode _elasticsearch_mode = mode::only_save;
|
mode _elasticsearch_mode = mode::only_save;
|
||||||
CURL *curl; // curl handler
|
CURL *curl; // curl handler
|
||||||
vector <string> bulk_lines; // vector of op lines
|
vector <string> bulk_lines; // vector of op lines
|
||||||
|
|
@ -75,20 +75,19 @@ class elasticsearch_plugin_impl
|
||||||
std::string bulk_line;
|
std::string bulk_line;
|
||||||
std::string index_name;
|
std::string index_name;
|
||||||
bool is_sync = false;
|
bool is_sync = false;
|
||||||
fc::time_point last_sync;
|
|
||||||
private:
|
private:
|
||||||
bool add_elasticsearch( const account_id_type account_id, const optional<operation_history_object>& oho, const uint32_t block_number );
|
bool add_elasticsearch( const account_id_type account_id, const optional<operation_history_object>& oho, const uint32_t block_number );
|
||||||
const account_transaction_history_object& addNewEntry(const account_statistics_object& stats_obj,
|
const account_transaction_history_object& addNewEntry(const account_statistics_object& stats_obj,
|
||||||
const account_id_type account_id,
|
const account_id_type& account_id,
|
||||||
const optional <operation_history_object>& oho);
|
const optional <operation_history_object>& oho);
|
||||||
const account_statistics_object& getStatsObject(const account_id_type account_id);
|
const account_statistics_object& getStatsObject(const account_id_type& account_id);
|
||||||
void growStats(const account_statistics_object& stats_obj, const account_transaction_history_object& ath);
|
void growStats(const account_statistics_object& stats_obj, const account_transaction_history_object& ath);
|
||||||
void getOperationType(const optional <operation_history_object>& oho);
|
void getOperationType(const optional <operation_history_object>& oho);
|
||||||
void doOperationHistory(const optional <operation_history_object>& oho);
|
void doOperationHistory(const optional <operation_history_object>& oho);
|
||||||
void doBlock(const optional <operation_history_object>& oho, const signed_block& b);
|
void doBlock(uint32_t trx_in_block, const signed_block& b);
|
||||||
void doVisitor(const optional <operation_history_object>& oho);
|
void doVisitor(const optional <operation_history_object>& oho);
|
||||||
void checkState(const fc::time_point_sec& block_time);
|
void checkState(const fc::time_point_sec& block_time);
|
||||||
void cleanObjects(const account_transaction_history_object& ath, account_id_type account_id);
|
void cleanObjects(const account_transaction_history_id_type& ath, const account_id_type& account_id);
|
||||||
void createBulkLine(const account_transaction_history_object& ath);
|
void createBulkLine(const account_transaction_history_object& ath);
|
||||||
void prepareBulk(const account_transaction_history_id_type& ath_id);
|
void prepareBulk(const account_transaction_history_id_type& ath_id);
|
||||||
void populateESstruct();
|
void populateESstruct();
|
||||||
|
|
@ -148,7 +147,7 @@ bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b
|
||||||
// populate what we can before impacted loop
|
// populate what we can before impacted loop
|
||||||
getOperationType(oho);
|
getOperationType(oho);
|
||||||
doOperationHistory(oho);
|
doOperationHistory(oho);
|
||||||
doBlock(oho, b);
|
doBlock(oho->trx_in_block, b);
|
||||||
if(_elasticsearch_visitor)
|
if(_elasticsearch_visitor)
|
||||||
doVisitor(oho);
|
doVisitor(oho);
|
||||||
|
|
||||||
|
|
@ -174,7 +173,11 @@ bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b
|
||||||
for( auto& account_id : impacted )
|
for( auto& account_id : impacted )
|
||||||
{
|
{
|
||||||
if(!add_elasticsearch( account_id, oho, b.block_num() ))
|
if(!add_elasticsearch( account_id, oho, b.block_num() ))
|
||||||
|
{
|
||||||
|
elog( "Error adding data to Elastic Search: block num ${b}, account ${a}, data ${d}",
|
||||||
|
("b",b.block_num()) ("a",account_id) ("d", oho) );
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we send bulk at end of block when we are in sync for better real time client experience
|
// we send bulk at end of block when we are in sync for better real time client experience
|
||||||
|
|
@ -185,23 +188,33 @@ bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b
|
||||||
{
|
{
|
||||||
prepare.clear();
|
prepare.clear();
|
||||||
if(!graphene::utilities::SendBulk(es))
|
if(!graphene::utilities::SendBulk(es))
|
||||||
|
{
|
||||||
|
// Note: although called with `std::move()`, `es` is not updated in `SendBulk()`
|
||||||
|
elog( "Error sending ${n} lines of bulk data to Elastic Search, the first lines are:",
|
||||||
|
("n",es.bulk_lines.size()) );
|
||||||
|
for( size_t i = 0; i < es.bulk_lines.size() && i < 10; ++i )
|
||||||
|
{
|
||||||
|
edump( (es.bulk_lines[i]) );
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
bulk_lines.clear();
|
bulk_lines.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bulk_lines.size() != limit_documents)
|
||||||
|
bulk_lines.reserve(limit_documents);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void elasticsearch_plugin_impl::checkState(const fc::time_point_sec& block_time)
|
void elasticsearch_plugin_impl::checkState(const fc::time_point_sec& block_time)
|
||||||
{
|
{
|
||||||
fc::time_point current_time(fc::time_point::now());
|
if((fc::time_point::now() - block_time) < fc::seconds(30))
|
||||||
if(((current_time - block_time) < fc::seconds(30)) || (current_time - last_sync > fc::seconds(60)))
|
|
||||||
{
|
{
|
||||||
limit_documents = _elasticsearch_bulk_sync;
|
limit_documents = _elasticsearch_bulk_sync;
|
||||||
is_sync = true;
|
is_sync = true;
|
||||||
last_sync = current_time;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -232,11 +245,11 @@ void elasticsearch_plugin_impl::doOperationHistory(const optional <operation_his
|
||||||
os.op = fc::json::to_string(oho->op);
|
os.op = fc::json::to_string(oho->op);
|
||||||
}
|
}
|
||||||
|
|
||||||
void elasticsearch_plugin_impl::doBlock(const optional <operation_history_object>& oho, const signed_block& b)
|
void elasticsearch_plugin_impl::doBlock(uint32_t trx_in_block, const signed_block& b)
|
||||||
{
|
{
|
||||||
std::string trx_id = "";
|
std::string trx_id = "";
|
||||||
if(oho->trx_in_block < b.transactions.size())
|
if(trx_in_block < b.transactions.size())
|
||||||
trx_id = b.transactions[oho->trx_in_block].id().str();
|
trx_id = b.transactions[trx_in_block].id().str();
|
||||||
bs.block_num = b.block_num();
|
bs.block_num = b.block_num();
|
||||||
bs.block_time = b.timestamp;
|
bs.block_time = b.timestamp;
|
||||||
bs.trx_id = trx_id;
|
bs.trx_id = trx_id;
|
||||||
|
|
@ -244,23 +257,41 @@ void elasticsearch_plugin_impl::doBlock(const optional <operation_history_object
|
||||||
|
|
||||||
void elasticsearch_plugin_impl::doVisitor(const optional <operation_history_object>& oho)
|
void elasticsearch_plugin_impl::doVisitor(const optional <operation_history_object>& oho)
|
||||||
{
|
{
|
||||||
|
graphene::chain::database& db = database();
|
||||||
|
|
||||||
operation_visitor o_v;
|
operation_visitor o_v;
|
||||||
oho->op.visit(o_v);
|
oho->op.visit(o_v);
|
||||||
|
|
||||||
|
auto fee_asset = o_v.fee_asset(db);
|
||||||
vs.fee_data.asset = o_v.fee_asset;
|
vs.fee_data.asset = o_v.fee_asset;
|
||||||
|
vs.fee_data.asset_name = fee_asset.symbol;
|
||||||
vs.fee_data.amount = o_v.fee_amount;
|
vs.fee_data.amount = o_v.fee_amount;
|
||||||
|
vs.fee_data.amount_units = (o_v.fee_amount.value)/(double)asset::scaled_precision(fee_asset.precision).value;
|
||||||
|
|
||||||
|
auto transfer_asset = o_v.transfer_asset_id(db);
|
||||||
vs.transfer_data.asset = o_v.transfer_asset_id;
|
vs.transfer_data.asset = o_v.transfer_asset_id;
|
||||||
|
vs.transfer_data.asset_name = transfer_asset.symbol;
|
||||||
vs.transfer_data.amount = o_v.transfer_amount;
|
vs.transfer_data.amount = o_v.transfer_amount;
|
||||||
|
vs.transfer_data.amount_units = (o_v.transfer_amount.value)/(double)asset::scaled_precision(transfer_asset.precision).value;
|
||||||
vs.transfer_data.from = o_v.transfer_from;
|
vs.transfer_data.from = o_v.transfer_from;
|
||||||
vs.transfer_data.to = o_v.transfer_to;
|
vs.transfer_data.to = o_v.transfer_to;
|
||||||
|
|
||||||
|
auto fill_pays_asset = o_v.fill_pays_asset_id(db);
|
||||||
|
auto fill_receives_asset = o_v.fill_receives_asset_id(db);
|
||||||
vs.fill_data.order_id = o_v.fill_order_id;
|
vs.fill_data.order_id = o_v.fill_order_id;
|
||||||
vs.fill_data.account_id = o_v.fill_account_id;
|
vs.fill_data.account_id = o_v.fill_account_id;
|
||||||
vs.fill_data.pays_asset_id = o_v.fill_pays_asset_id;
|
vs.fill_data.pays_asset_id = o_v.fill_pays_asset_id;
|
||||||
|
vs.fill_data.pays_asset_name = fill_pays_asset.symbol;
|
||||||
vs.fill_data.pays_amount = o_v.fill_pays_amount;
|
vs.fill_data.pays_amount = o_v.fill_pays_amount;
|
||||||
|
vs.fill_data.pays_amount_units = (o_v.fill_pays_amount.value)/(double)asset::scaled_precision(fill_pays_asset.precision).value;
|
||||||
vs.fill_data.receives_asset_id = o_v.fill_receives_asset_id;
|
vs.fill_data.receives_asset_id = o_v.fill_receives_asset_id;
|
||||||
|
vs.fill_data.receives_asset_name = fill_receives_asset.symbol;
|
||||||
vs.fill_data.receives_amount = o_v.fill_receives_amount;
|
vs.fill_data.receives_amount = o_v.fill_receives_amount;
|
||||||
|
vs.fill_data.receives_amount_units = (o_v.fill_receives_amount.value)/(double)asset::scaled_precision(fill_receives_asset.precision).value;
|
||||||
|
|
||||||
|
auto fill_price = (o_v.fill_receives_amount.value/(double)asset::scaled_precision(fill_receives_asset.precision).value) /
|
||||||
|
(o_v.fill_pays_amount.value/(double)asset::scaled_precision(fill_pays_asset.precision).value);
|
||||||
|
vs.fill_data.fill_price_units = fill_price;
|
||||||
//vs.fill_data.fill_price = o_v.fill_fill_price;
|
//vs.fill_data.fill_price = o_v.fill_fill_price;
|
||||||
//vs.fill_data.is_maker = o_v.fill_is_maker;
|
//vs.fill_data.is_maker = o_v.fill_is_maker;
|
||||||
}
|
}
|
||||||
|
|
@ -276,13 +307,22 @@ bool elasticsearch_plugin_impl::add_elasticsearch( const account_id_type account
|
||||||
createBulkLine(ath);
|
createBulkLine(ath);
|
||||||
prepareBulk(ath.id);
|
prepareBulk(ath.id);
|
||||||
}
|
}
|
||||||
cleanObjects(ath, account_id);
|
cleanObjects(ath.id, account_id);
|
||||||
|
|
||||||
if (curl && bulk_lines.size() >= limit_documents) { // we are in bulk time, ready to add data to elasticsearech
|
if (curl && bulk_lines.size() >= limit_documents) { // we are in bulk time, ready to add data to elasticsearech
|
||||||
prepare.clear();
|
prepare.clear();
|
||||||
populateESstruct();
|
populateESstruct();
|
||||||
if(!graphene::utilities::SendBulk(es))
|
if(!graphene::utilities::SendBulk(es))
|
||||||
|
{
|
||||||
|
// Note: although called with `std::move()`, `es` is not updated in `SendBulk()`
|
||||||
|
elog( "Error sending ${n} lines of bulk data to Elastic Search, the first lines are:",
|
||||||
|
("n",es.bulk_lines.size()) );
|
||||||
|
for( size_t i = 0; i < es.bulk_lines.size() && i < 10; ++i )
|
||||||
|
{
|
||||||
|
edump( (es.bulk_lines[i]) );
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
bulk_lines.clear();
|
bulk_lines.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -290,15 +330,16 @@ bool elasticsearch_plugin_impl::add_elasticsearch( const account_id_type account
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const account_statistics_object& elasticsearch_plugin_impl::getStatsObject(const account_id_type account_id)
|
const account_statistics_object& elasticsearch_plugin_impl::getStatsObject(const account_id_type& account_id)
|
||||||
{
|
{
|
||||||
graphene::chain::database& db = database();
|
graphene::chain::database& db = database();
|
||||||
const auto &acct = db.get<account_object>(account_id);
|
const auto &stats_obj = db.get_account_stats_by_owner(account_id);
|
||||||
return acct.statistics(db);
|
|
||||||
|
return stats_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
const account_transaction_history_object& elasticsearch_plugin_impl::addNewEntry(const account_statistics_object& stats_obj,
|
const account_transaction_history_object& elasticsearch_plugin_impl::addNewEntry(const account_statistics_object& stats_obj,
|
||||||
const account_id_type account_id,
|
const account_id_type& account_id,
|
||||||
const optional <operation_history_object>& oho)
|
const optional <operation_history_object>& oho)
|
||||||
{
|
{
|
||||||
graphene::chain::database& db = database();
|
graphene::chain::database& db = database();
|
||||||
|
|
@ -340,19 +381,21 @@ void elasticsearch_plugin_impl::prepareBulk(const account_transaction_history_id
|
||||||
fc::mutable_variant_object bulk_header;
|
fc::mutable_variant_object bulk_header;
|
||||||
bulk_header["_index"] = index_name;
|
bulk_header["_index"] = index_name;
|
||||||
bulk_header["_type"] = "data";
|
bulk_header["_type"] = "data";
|
||||||
bulk_header["_id"] = fc::to_string(ath_id.space_id) + "." + fc::to_string(ath_id.type_id) + "." + ath_id.instance;
|
bulk_header["_id"] = fc::to_string(ath_id.space_id) + "." + fc::to_string(ath_id.type_id) + "."
|
||||||
prepare = graphene::utilities::createBulk(bulk_header, bulk_line);
|
+ fc::to_string(ath_id.instance.value);
|
||||||
bulk_lines.insert(bulk_lines.end(), prepare.begin(), prepare.end());
|
prepare = graphene::utilities::createBulk(bulk_header, std::move(bulk_line));
|
||||||
|
std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk_lines));
|
||||||
|
prepare.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void elasticsearch_plugin_impl::cleanObjects(const account_transaction_history_object& ath, account_id_type account_id)
|
void elasticsearch_plugin_impl::cleanObjects(const account_transaction_history_id_type& ath_id, const account_id_type& account_id)
|
||||||
{
|
{
|
||||||
graphene::chain::database& db = database();
|
graphene::chain::database& db = database();
|
||||||
// remove everything except current object from ath
|
// remove everything except current object from ath
|
||||||
const auto &his_idx = db.get_index_type<account_transaction_history_index>();
|
const auto &his_idx = db.get_index_type<account_transaction_history_index>();
|
||||||
const auto &by_seq_idx = his_idx.indices().get<by_seq>();
|
const auto &by_seq_idx = his_idx.indices().get<by_seq>();
|
||||||
auto itr = by_seq_idx.lower_bound(boost::make_tuple(account_id, 0));
|
auto itr = by_seq_idx.lower_bound(boost::make_tuple(account_id, 0));
|
||||||
if (itr != by_seq_idx.end() && itr->account == account_id && itr->id != ath.id) {
|
if (itr != by_seq_idx.end() && itr->account == account_id && itr->id != ath_id) {
|
||||||
// if found, remove the entry
|
// if found, remove the entry
|
||||||
const auto remove_op_id = itr->operation_id;
|
const auto remove_op_id = itr->operation_id;
|
||||||
const auto itr_remove = itr;
|
const auto itr_remove = itr;
|
||||||
|
|
@ -377,9 +420,12 @@ void elasticsearch_plugin_impl::cleanObjects(const account_transaction_history_o
|
||||||
void elasticsearch_plugin_impl::populateESstruct()
|
void elasticsearch_plugin_impl::populateESstruct()
|
||||||
{
|
{
|
||||||
es.curl = curl;
|
es.curl = curl;
|
||||||
es.bulk_lines = bulk_lines;
|
es.bulk_lines = std::move(bulk_lines);
|
||||||
es.elasticsearch_url = _elasticsearch_node_url;
|
es.elasticsearch_url = _elasticsearch_node_url;
|
||||||
es.auth = _elasticsearch_basic_auth;
|
es.auth = _elasticsearch_basic_auth;
|
||||||
|
es.index_prefix = _elasticsearch_index_prefix;
|
||||||
|
es.endpoint = "";
|
||||||
|
es.query = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace detail
|
} // end namespace detail
|
||||||
|
|
@ -421,11 +467,11 @@ void elasticsearch_plugin::plugin_set_program_options(
|
||||||
("elasticsearch-index-prefix", boost::program_options::value<std::string>(),
|
("elasticsearch-index-prefix", boost::program_options::value<std::string>(),
|
||||||
"Add a prefix to the index(peerplays-)")
|
"Add a prefix to the index(peerplays-)")
|
||||||
("elasticsearch-operation-object", boost::program_options::value<bool>(),
|
("elasticsearch-operation-object", boost::program_options::value<bool>(),
|
||||||
"Save operation as object(false)")
|
"Save operation as object(true)")
|
||||||
("elasticsearch-start-es-after-block", boost::program_options::value<uint32_t>(),
|
("elasticsearch-start-es-after-block", boost::program_options::value<uint32_t>(),
|
||||||
"Start doing ES job after block(0)")
|
"Start doing ES job after block(0)")
|
||||||
("elasticsearch-operation-string", boost::program_options::value<bool>(),
|
("elasticsearch-operation-string", boost::program_options::value<bool>(),
|
||||||
"Save operation as string. Needed to serve history api calls(true)")
|
"Save operation as string. Needed to serve history api calls(false)")
|
||||||
("elasticsearch-mode", boost::program_options::value<uint16_t>(),
|
("elasticsearch-mode", boost::program_options::value<uint16_t>(),
|
||||||
"Mode of operation: only_save(0), only_query(1), all(2) - Default: 0")
|
"Mode of operation: only_save(0), only_query(1), all(2) - Default: 0")
|
||||||
;
|
;
|
||||||
|
|
@ -467,18 +513,18 @@ void elasticsearch_plugin::plugin_initialize(const boost::program_options::varia
|
||||||
if (options.count("elasticsearch-mode")) {
|
if (options.count("elasticsearch-mode")) {
|
||||||
const auto option_number = options["elasticsearch-mode"].as<uint16_t>();
|
const auto option_number = options["elasticsearch-mode"].as<uint16_t>();
|
||||||
if(option_number > mode::all)
|
if(option_number > mode::all)
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Elasticsearch mode not valid");
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Elasticsearch mode not valid");
|
||||||
my->_elasticsearch_mode = static_cast<mode>(options["elasticsearch-mode"].as<uint16_t>());
|
my->_elasticsearch_mode = static_cast<mode>(options["elasticsearch-mode"].as<uint16_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(my->_elasticsearch_mode != mode::only_query) {
|
if(my->_elasticsearch_mode != mode::only_query) {
|
||||||
if (my->_elasticsearch_mode == mode::all && !my->_elasticsearch_operation_string)
|
if (my->_elasticsearch_mode == mode::all && !my->_elasticsearch_operation_string)
|
||||||
FC_THROW_EXCEPTION(fc::exception,
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception,
|
||||||
"If elasticsearch-mode is set to all then elasticsearch-operation-string need to be true");
|
"If elasticsearch-mode is set to all then elasticsearch-operation-string need to be true");
|
||||||
|
|
||||||
database().applied_block.connect([this](const signed_block &b) {
|
database().applied_block.connect([this](const signed_block &b) {
|
||||||
if (!my->update_account_histories(b))
|
if (!my->update_account_histories(b))
|
||||||
FC_THROW_EXCEPTION(fc::exception,
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception,
|
||||||
"Error populating ES database, we are going to keep trying.");
|
"Error populating ES database, we are going to keep trying.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -563,13 +609,12 @@ vector<operation_history_object> elasticsearch_plugin::get_account_history(
|
||||||
const auto response = graphene::utilities::simpleQuery(es);
|
const auto response = graphene::utilities::simpleQuery(es);
|
||||||
variant variant_response = fc::json::from_string(response);
|
variant variant_response = fc::json::from_string(response);
|
||||||
|
|
||||||
const auto hits = variant_response["hits"]["total"]["value"];
|
const auto hits = variant_response["hits"]["total"];
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
if( hits.is_object() ) // ES-7 ?
|
if( hits.is_object() ) // ES-7 ?
|
||||||
size = static_cast<uint32_t>(hits["value"].as_uint64());
|
size = static_cast<uint32_t>(hits["value"].as_uint64());
|
||||||
else // probably ES-6
|
else // probably ES-6
|
||||||
size = static_cast<uint32_t>(hits.as_uint64());
|
size = static_cast<uint32_t>(hits.as_uint64());
|
||||||
|
|
||||||
size = std::min( size, limit );
|
size = std::min( size, limit );
|
||||||
|
|
||||||
for(unsigned i=0; i<size; i++)
|
for(unsigned i=0; i<size; i++)
|
||||||
|
|
|
||||||
|
|
@ -152,12 +152,16 @@ struct block_struct {
|
||||||
|
|
||||||
struct fee_struct {
|
struct fee_struct {
|
||||||
asset_id_type asset;
|
asset_id_type asset;
|
||||||
|
std::string asset_name;
|
||||||
share_type amount;
|
share_type amount;
|
||||||
|
double amount_units;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct transfer_struct {
|
struct transfer_struct {
|
||||||
asset_id_type asset;
|
asset_id_type asset;
|
||||||
|
std::string asset_name;
|
||||||
share_type amount;
|
share_type amount;
|
||||||
|
double amount_units;
|
||||||
account_id_type from;
|
account_id_type from;
|
||||||
account_id_type to;
|
account_id_type to;
|
||||||
};
|
};
|
||||||
|
|
@ -166,10 +170,15 @@ struct fill_struct {
|
||||||
object_id_type order_id;
|
object_id_type order_id;
|
||||||
account_id_type account_id;
|
account_id_type account_id;
|
||||||
asset_id_type pays_asset_id;
|
asset_id_type pays_asset_id;
|
||||||
|
std::string pays_asset_name;
|
||||||
share_type pays_amount;
|
share_type pays_amount;
|
||||||
|
double pays_amount_units;
|
||||||
asset_id_type receives_asset_id;
|
asset_id_type receives_asset_id;
|
||||||
|
std::string receives_asset_name;
|
||||||
share_type receives_amount;
|
share_type receives_amount;
|
||||||
|
double receives_amount_units;
|
||||||
double fill_price;
|
double fill_price;
|
||||||
|
double fill_price_units;
|
||||||
bool is_maker;
|
bool is_maker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -258,6 +267,23 @@ struct adaptor_struct {
|
||||||
{
|
{
|
||||||
o["initializer"] = fc::json::to_string(o["initializer"]);
|
o["initializer"] = fc::json::to_string(o["initializer"]);
|
||||||
}
|
}
|
||||||
|
if (o.find("policy") != o.end())
|
||||||
|
{
|
||||||
|
o["policy"] = fc::json::to_string(o["policy"]);
|
||||||
|
}
|
||||||
|
if (o.find("predicates") != o.end())
|
||||||
|
{
|
||||||
|
o["predicates"] = fc::json::to_string(o["predicates"]);
|
||||||
|
}
|
||||||
|
if (o.find("active_special_authority") != o.end())
|
||||||
|
{
|
||||||
|
o["active_special_authority"] = fc::json::to_string(o["active_special_authority"]);
|
||||||
|
}
|
||||||
|
if (o.find("owner_special_authority") != o.end())
|
||||||
|
{
|
||||||
|
o["owner_special_authority"] = fc::json::to_string(o["owner_special_authority"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
variant v;
|
variant v;
|
||||||
fc::to_variant(o, v, FC_PACK_MAX_DEPTH);
|
fc::to_variant(o, v, FC_PACK_MAX_DEPTH);
|
||||||
|
|
@ -277,13 +303,16 @@ struct adaptor_struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} } //graphene::elasticsearch
|
} } //graphene::elasticsearch
|
||||||
|
|
||||||
FC_REFLECT_ENUM( graphene::elasticsearch::mode, (only_save)(only_query)(all) )
|
FC_REFLECT_ENUM( graphene::elasticsearch::mode, (only_save)(only_query)(all) )
|
||||||
FC_REFLECT( graphene::elasticsearch::operation_history_struct, (trx_in_block)(op_in_trx)(operation_result)(virtual_op)(op)(op_object) )
|
FC_REFLECT( graphene::elasticsearch::operation_history_struct, (trx_in_block)(op_in_trx)(operation_result)(virtual_op)(op)(op_object) )
|
||||||
FC_REFLECT( graphene::elasticsearch::block_struct, (block_num)(block_time)(trx_id) )
|
FC_REFLECT( graphene::elasticsearch::block_struct, (block_num)(block_time)(trx_id) )
|
||||||
FC_REFLECT( graphene::elasticsearch::fee_struct, (asset)(amount) )
|
FC_REFLECT( graphene::elasticsearch::fee_struct, (asset)(asset_name)(amount)(amount_units) )
|
||||||
FC_REFLECT( graphene::elasticsearch::transfer_struct, (asset)(amount)(from)(to) )
|
FC_REFLECT( graphene::elasticsearch::transfer_struct, (asset)(asset_name)(amount)(amount_units)(from)(to) )
|
||||||
FC_REFLECT( graphene::elasticsearch::fill_struct, (order_id)(account_id)(pays_asset_id)(pays_amount)(receives_asset_id)(receives_amount)(fill_price)(is_maker))
|
FC_REFLECT( graphene::elasticsearch::fill_struct, (order_id)(account_id)(pays_asset_id)(pays_asset_name)(pays_amount)(pays_amount_units)
|
||||||
|
(receives_asset_id)(receives_asset_name)(receives_amount)(receives_amount_units)(fill_price)
|
||||||
|
(fill_price_units)(is_maker))
|
||||||
FC_REFLECT( graphene::elasticsearch::visitor_struct, (fee_data)(transfer_data)(fill_data) )
|
FC_REFLECT( graphene::elasticsearch::visitor_struct, (fee_data)(transfer_data)(fill_data) )
|
||||||
FC_REFLECT( graphene::elasticsearch::bulk_struct, (account_history)(operation_history)(operation_type)(operation_id_num)(block_data)(additional_data) )
|
FC_REFLECT( graphene::elasticsearch::bulk_struct, (account_history)(operation_history)(operation_type)(operation_id_num)(block_data)(additional_data) )
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,22 @@ add_library( graphene_es_objects
|
||||||
es_objects.cpp
|
es_objects.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries( graphene_es_objects PRIVATE graphene_plugin curl )
|
find_curl()
|
||||||
target_include_directories( graphene_es_objects
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
|
||||||
|
|
||||||
|
include_directories(${CURL_INCLUDE_DIRS})
|
||||||
|
if(CURL_STATICLIB)
|
||||||
|
SET_TARGET_PROPERTIES(graphene_es_objects PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS "CURL_STATICLIB")
|
||||||
|
endif(CURL_STATICLIB)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_source_files_properties(es_objects.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
set_source_files_properties(es_objects.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
|
target_link_libraries( graphene_es_objects PRIVATE graphene_plugin ${CURL_LIBRARIES} )
|
||||||
|
target_include_directories( graphene_es_objects
|
||||||
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||||
|
|
||||||
|
|
||||||
install( TARGETS
|
install( TARGETS
|
||||||
graphene_es_objects
|
graphene_es_objects
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,22 @@
|
||||||
#include <graphene/chain/asset_object.hpp>
|
#include <graphene/chain/asset_object.hpp>
|
||||||
#include <graphene/chain/account_object.hpp>
|
#include <graphene/chain/account_object.hpp>
|
||||||
|
|
||||||
|
#include <graphene/chain/account_role_object.hpp>
|
||||||
|
#include <graphene/chain/committee_member_object.hpp>
|
||||||
|
#include <graphene/chain/nft_object.hpp>
|
||||||
|
#include <graphene/chain/offer_object.hpp>
|
||||||
|
#include <graphene/chain/sidechain_address_object.hpp>
|
||||||
|
#include <graphene/chain/sidechain_transaction_object.hpp>
|
||||||
|
#include <graphene/chain/son_object.hpp>
|
||||||
|
#include <graphene/chain/son_proposal_object.hpp>
|
||||||
|
#include <graphene/chain/son_wallet_object.hpp>
|
||||||
|
#include <graphene/chain/son_wallet_deposit_object.hpp>
|
||||||
|
#include <graphene/chain/son_wallet_withdraw_object.hpp>
|
||||||
|
#include <graphene/chain/transaction_object.hpp>
|
||||||
|
#include <graphene/chain/vesting_balance_object.hpp>
|
||||||
|
#include <graphene/chain/witness_object.hpp>
|
||||||
|
#include <graphene/chain/worker_object.hpp>
|
||||||
|
|
||||||
#include <graphene/utilities/elasticsearch.hpp>
|
#include <graphene/utilities/elasticsearch.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace es_objects {
|
namespace graphene { namespace es_objects {
|
||||||
|
|
@ -61,6 +77,16 @@ class es_objects_plugin_impl
|
||||||
bool _es_objects_balances = true;
|
bool _es_objects_balances = true;
|
||||||
bool _es_objects_limit_orders = true;
|
bool _es_objects_limit_orders = true;
|
||||||
bool _es_objects_asset_bitasset = true;
|
bool _es_objects_asset_bitasset = true;
|
||||||
|
|
||||||
|
bool _es_objects_account_role = true;
|
||||||
|
bool _es_objects_committee_member = true;
|
||||||
|
bool _es_objects_nft = true;
|
||||||
|
bool _es_objects_son = true;
|
||||||
|
bool _es_objects_transaction = true;
|
||||||
|
bool _es_objects_vesting_balance = true;
|
||||||
|
bool _es_objects_witness = true;
|
||||||
|
bool _es_objects_worker = true;
|
||||||
|
|
||||||
std::string _es_objects_index_prefix = "ppobjects-";
|
std::string _es_objects_index_prefix = "ppobjects-";
|
||||||
uint32_t _es_objects_start_es_after_block = 0;
|
uint32_t _es_objects_start_es_after_block = 0;
|
||||||
CURL *curl; // curl handler
|
CURL *curl; // curl handler
|
||||||
|
|
@ -79,7 +105,6 @@ class es_objects_plugin_impl
|
||||||
|
|
||||||
bool es_objects_plugin_impl::genesis()
|
bool es_objects_plugin_impl::genesis()
|
||||||
{
|
{
|
||||||
|
|
||||||
ilog("elasticsearch OBJECTS: inserting data from genesis");
|
ilog("elasticsearch OBJECTS: inserting data from genesis");
|
||||||
|
|
||||||
graphene::chain::database &db = _self.database();
|
graphene::chain::database &db = _self.database();
|
||||||
|
|
@ -112,13 +137,142 @@ bool es_objects_plugin_impl::genesis()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_es_objects_account_role) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::account_role_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const account_role_object *>(obj);
|
||||||
|
prepareTemplate<account_role_object>(*b, "account_role");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_committee_member) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::committee_member_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const committee_member_object *>(obj);
|
||||||
|
prepareTemplate<committee_member_object>(*b, "committee_member");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_nft) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::nft_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const nft_object *>(obj);
|
||||||
|
prepareTemplate<nft_object>(*b, "nft");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_nft) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::nft_metadata_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const nft_metadata_object *>(obj);
|
||||||
|
prepareTemplate<nft_metadata_object>(*b, "nft_metadata");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_nft) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::offer_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const offer_object *>(obj);
|
||||||
|
prepareTemplate<offer_object>(*b, "offer");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::sidechain_address_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const sidechain_address_object *>(obj);
|
||||||
|
prepareTemplate<sidechain_address_object>(*b, "sidechain_address");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::sidechain_transaction_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const sidechain_transaction_object *>(obj);
|
||||||
|
prepareTemplate<sidechain_transaction_object>(*b, "sidechain_transaction");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::son_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const son_object *>(obj);
|
||||||
|
prepareTemplate<son_object>(*b, "son");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::son_proposal_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const son_proposal_object *>(obj);
|
||||||
|
prepareTemplate<son_proposal_object>(*b, "son_proposal");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::son_wallet_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const son_wallet_object *>(obj);
|
||||||
|
prepareTemplate<son_wallet_object>(*b, "son_wallet");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::son_wallet_deposit_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const son_wallet_deposit_object *>(obj);
|
||||||
|
prepareTemplate<son_wallet_deposit_object>(*b, "son_wallet_deposit");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_son) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::son_wallet_withdraw_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const son_wallet_withdraw_object *>(obj);
|
||||||
|
prepareTemplate<son_wallet_withdraw_object>(*b, "son_wallet_withdraw");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_transaction) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::transaction_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const transaction_object *>(obj);
|
||||||
|
prepareTemplate<transaction_object>(*b, "transaction");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_vesting_balance) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::vesting_balance_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const vesting_balance_object *>(obj);
|
||||||
|
prepareTemplate<vesting_balance_object>(*b, "vesting_balance");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_witness) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::witness_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const witness_object *>(obj);
|
||||||
|
prepareTemplate<witness_object>(*b, "witness");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_es_objects_worker) {
|
||||||
|
auto &idx = db.get_index_type<graphene::chain::worker_index>();
|
||||||
|
idx.inspect_all_objects([this, &db](const graphene::db::object &o) {
|
||||||
|
auto obj = db.find_object(o.id);
|
||||||
|
auto b = static_cast<const worker_object *>(obj);
|
||||||
|
prepareTemplate<worker_object>(*b, "worker");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
graphene::utilities::ES es;
|
graphene::utilities::ES es;
|
||||||
es.curl = curl;
|
es.curl = curl;
|
||||||
es.bulk_lines = bulk;
|
es.bulk_lines = bulk;
|
||||||
es.elasticsearch_url = _es_objects_elasticsearch_url;
|
es.elasticsearch_url = _es_objects_elasticsearch_url;
|
||||||
es.auth = _es_objects_auth;
|
es.auth = _es_objects_auth;
|
||||||
if (!graphene::utilities::SendBulk(es))
|
if (!graphene::utilities::SendBulk(es))
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Error inserting genesis data.");
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Error inserting genesis data.");
|
||||||
else
|
else
|
||||||
bulk.clear();
|
bulk.clear();
|
||||||
|
|
||||||
|
|
@ -197,6 +351,150 @@ bool es_objects_plugin_impl::index_database(const vector<object_id_type>& ids, s
|
||||||
else
|
else
|
||||||
prepareTemplate<asset_bitasset_data_object>(*ba, "bitasset");
|
prepareTemplate<asset_bitasset_data_object>(*ba, "bitasset");
|
||||||
}
|
}
|
||||||
|
} else if (value.is<account_role_object>() && _es_objects_account_role) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const account_role_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "account_role");
|
||||||
|
else
|
||||||
|
prepareTemplate<account_role_object>(*ba, "account_role");
|
||||||
|
}
|
||||||
|
} else if (value.is<committee_member_object>() && _es_objects_committee_member) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const committee_member_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "committee_member");
|
||||||
|
else
|
||||||
|
prepareTemplate<committee_member_object>(*ba, "committee_member");
|
||||||
|
}
|
||||||
|
} else if (value.is<nft_object>() && _es_objects_nft) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const nft_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "nft");
|
||||||
|
else
|
||||||
|
prepareTemplate<nft_object>(*ba, "nft");
|
||||||
|
}
|
||||||
|
} else if (value.is<nft_metadata_object>() && _es_objects_nft) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const nft_metadata_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "nft_metadata");
|
||||||
|
else
|
||||||
|
prepareTemplate<nft_metadata_object>(*ba, "nft_metadata");
|
||||||
|
}
|
||||||
|
} else if (value.is<offer_object>() && _es_objects_nft) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const offer_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "offer");
|
||||||
|
else
|
||||||
|
prepareTemplate<offer_object>(*ba, "offer");
|
||||||
|
}
|
||||||
|
} else if (value.is<sidechain_address_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const sidechain_address_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "sidechain_address");
|
||||||
|
else
|
||||||
|
prepareTemplate<sidechain_address_object>(*ba, "sidechain_address");
|
||||||
|
}
|
||||||
|
} else if (value.is<sidechain_transaction_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const sidechain_transaction_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "sidechain_transaction");
|
||||||
|
else
|
||||||
|
prepareTemplate<sidechain_transaction_object>(*ba, "sidechain_transaction");
|
||||||
|
}
|
||||||
|
} else if (value.is<son_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const son_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "son");
|
||||||
|
else
|
||||||
|
prepareTemplate<son_object>(*ba, "son");
|
||||||
|
}
|
||||||
|
} else if (value.is<son_proposal_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const son_proposal_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "son_proposal");
|
||||||
|
else
|
||||||
|
prepareTemplate<son_proposal_object>(*ba, "son_proposal");
|
||||||
|
}
|
||||||
|
} else if (value.is<son_wallet_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const son_wallet_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "son_wallet");
|
||||||
|
else
|
||||||
|
prepareTemplate<son_wallet_object>(*ba, "son_wallet");
|
||||||
|
}
|
||||||
|
} else if (value.is<son_wallet_deposit_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const son_wallet_deposit_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "son_wallet_deposit");
|
||||||
|
else
|
||||||
|
prepareTemplate<son_wallet_deposit_object>(*ba, "son_wallet_deposit");
|
||||||
|
}
|
||||||
|
} else if (value.is<son_wallet_withdraw_object>() && _es_objects_son) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const son_wallet_withdraw_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "son_wallet_withdraw");
|
||||||
|
else
|
||||||
|
prepareTemplate<son_wallet_withdraw_object>(*ba, "son_wallet_withdraw");
|
||||||
|
}
|
||||||
|
} else if (value.is<transaction_object>() && _es_objects_transaction) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const transaction_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "transaction");
|
||||||
|
else
|
||||||
|
prepareTemplate<transaction_object>(*ba, "transaction");
|
||||||
|
}
|
||||||
|
} else if (value.is<vesting_balance_object>() && _es_objects_vesting_balance) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const vesting_balance_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "vesting_balance");
|
||||||
|
else
|
||||||
|
prepareTemplate<vesting_balance_object>(*ba, "vesting_balance");
|
||||||
|
}
|
||||||
|
} else if (value.is<witness_object>() && _es_objects_witness) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const witness_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "witness");
|
||||||
|
else
|
||||||
|
prepareTemplate<witness_object>(*ba, "witness");
|
||||||
|
}
|
||||||
|
} else if (value.is<worker_object>() && _es_objects_worker) {
|
||||||
|
auto obj = db.find_object(value);
|
||||||
|
auto ba = static_cast<const worker_object *>(obj);
|
||||||
|
if (ba != nullptr) {
|
||||||
|
if (action == "delete")
|
||||||
|
remove_from_database(ba->id, "worker");
|
||||||
|
else
|
||||||
|
prepareTemplate<worker_object>(*ba, "worker");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,52 +594,39 @@ void es_objects_plugin::plugin_set_program_options(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cli.add_options()
|
cli.add_options()
|
||||||
("es-objects-elasticsearch-url", boost::program_options::value<std::string>(), "Elasticsearch node url(http://localhost:9200/)")
|
("es-objects-elasticsearch-url", boost::program_options::value<std::string>(),
|
||||||
|
"Elasticsearch node url(http://localhost:9200/)")
|
||||||
("es-objects-auth", boost::program_options::value<std::string>(), "Basic auth username:password('')")
|
("es-objects-auth", boost::program_options::value<std::string>(), "Basic auth username:password('')")
|
||||||
("es-objects-bulk-replay", boost::program_options::value<uint32_t>(), "Number of bulk documents to index on replay(10000)")
|
("es-objects-bulk-replay", boost::program_options::value<uint32_t>(),
|
||||||
("es-objects-bulk-sync", boost::program_options::value<uint32_t>(), "Number of bulk documents to index on a synchronized chain(100)")
|
"Number of bulk documents to index on replay(10000)")
|
||||||
|
("es-objects-bulk-sync", boost::program_options::value<uint32_t>(),
|
||||||
|
"Number of bulk documents to index on a synchronized chain(100)")
|
||||||
("es-objects-proposals", boost::program_options::value<bool>(), "Store proposal objects(true)")
|
("es-objects-proposals", boost::program_options::value<bool>(), "Store proposal objects(true)")
|
||||||
("es-objects-accounts", boost::program_options::value<bool>(), "Store account objects(true)")
|
("es-objects-accounts", boost::program_options::value<bool>(), "Store account objects(true)")
|
||||||
("es-objects-assets", boost::program_options::value<bool>(), "Store asset objects(true)")
|
("es-objects-assets", boost::program_options::value<bool>(), "Store asset objects(true)")
|
||||||
("es-objects-balances", boost::program_options::value<bool>(), "Store balances objects(true)")
|
("es-objects-balances", boost::program_options::value<bool>(), "Store balances objects(true)")
|
||||||
("es-objects-limit-orders", boost::program_options::value<bool>(), "Store limit order objects(true)")
|
("es-objects-limit-orders", boost::program_options::value<bool>(), "Store limit order objects(false)")
|
||||||
("es-objects-asset-bitasset", boost::program_options::value<bool>(), "Store feed data(true)")
|
("es-objects-bitasset", boost::program_options::value<bool>(), "Store feed data(true)")
|
||||||
("es-objects-index-prefix", boost::program_options::value<std::string>(), "Add a prefix to the index(ppobjects-)")
|
("es-objects-account-role", boost::program_options::value<bool>(), "Store account role objects (true)")
|
||||||
("es-objects-keep-only-current", boost::program_options::value<bool>(), "Keep only current state of the objects(true)")
|
("es-objects-committee-member", boost::program_options::value<bool>(), "Store committee member objects(true)")
|
||||||
("es-objects-start-es-after-block", boost::program_options::value<uint32_t>(), "Start doing ES job after block(0)")
|
("es-objects-nft", boost::program_options::value<bool>(), "Store nft objects (true)")
|
||||||
|
("es-objects-son", boost::program_options::value<bool>(), "Store son objects (true)")
|
||||||
|
("es-objects-transaction", boost::program_options::value<bool>(), "Store transaction objects (true)")
|
||||||
|
("es-objects-vesting-balance", boost::program_options::value<bool>(), "Store vesting balance objects (true)")
|
||||||
|
("es-objects-witness", boost::program_options::value<bool>(), "Store witness objects (true)")
|
||||||
|
("es-objects-worker", boost::program_options::value<bool>(), "Store worker objects (true)")
|
||||||
|
("es-objects-index-prefix", boost::program_options::value<std::string>(),
|
||||||
|
"Add a prefix to the index(ppobjects-)")
|
||||||
|
("es-objects-keep-only-current", boost::program_options::value<bool>(),
|
||||||
|
"Keep only current state of the objects(true)")
|
||||||
|
("es-objects-start-es-after-block", boost::program_options::value<uint32_t>(),
|
||||||
|
"Start doing ES job after block(0)")
|
||||||
;
|
;
|
||||||
cfg.add(cli);
|
cfg.add(cli);
|
||||||
}
|
}
|
||||||
|
|
||||||
void es_objects_plugin::plugin_initialize(const boost::program_options::variables_map& options)
|
void es_objects_plugin::plugin_initialize(const boost::program_options::variables_map& options)
|
||||||
{
|
{
|
||||||
database().applied_block.connect([this](const signed_block &b) {
|
|
||||||
if(b.block_num() == 1) {
|
|
||||||
if (!my->genesis())
|
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Error populating genesis data.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
database().new_objects.connect([this]( const vector<object_id_type>& ids, const flat_set<account_id_type>& impacted_accounts ) {
|
|
||||||
if(!my->index_database(ids, "create"))
|
|
||||||
{
|
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Error creating object from ES database, we are going to keep trying.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
database().changed_objects.connect([this]( const vector<object_id_type>& ids, const flat_set<account_id_type>& impacted_accounts ) {
|
|
||||||
if(!my->index_database(ids, "update"))
|
|
||||||
{
|
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Error updating object from ES database, we are going to keep trying.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
database().removed_objects.connect([this](const vector<object_id_type>& ids, const vector<const object*>& objs, const flat_set<account_id_type>& impacted_accounts) {
|
|
||||||
if(!my->index_database(ids, "delete"))
|
|
||||||
{
|
|
||||||
FC_THROW_EXCEPTION(fc::exception, "Error deleting object from ES database, we are going to keep trying.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (options.count("es-objects-elasticsearch-url")) {
|
if (options.count("es-objects-elasticsearch-url")) {
|
||||||
my->_es_objects_elasticsearch_url = options["es-objects-elasticsearch-url"].as<std::string>();
|
my->_es_objects_elasticsearch_url = options["es-objects-elasticsearch-url"].as<std::string>();
|
||||||
}
|
}
|
||||||
|
|
@ -372,6 +657,30 @@ void es_objects_plugin::plugin_initialize(const boost::program_options::variable
|
||||||
if (options.count("es-objects-asset-bitasset")) {
|
if (options.count("es-objects-asset-bitasset")) {
|
||||||
my->_es_objects_asset_bitasset = options["es-objects-asset-bitasset"].as<bool>();
|
my->_es_objects_asset_bitasset = options["es-objects-asset-bitasset"].as<bool>();
|
||||||
}
|
}
|
||||||
|
if (options.count("es-objects-account-role")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-account-role"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-committee-member")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-committee-member"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-nft")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-nft"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-son")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-son"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-transaction")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-transaction"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-vesting-balance")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-vesting-balance"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-witness")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-witness"].as<bool>();
|
||||||
|
}
|
||||||
|
if (options.count("es-objects-worker")) {
|
||||||
|
my->_es_objects_balances = options["es-objects-worker"].as<bool>();
|
||||||
|
}
|
||||||
if (options.count("es-objects-index-prefix")) {
|
if (options.count("es-objects-index-prefix")) {
|
||||||
my->_es_objects_index_prefix = options["es-objects-index-prefix"].as<std::string>();
|
my->_es_objects_index_prefix = options["es-objects-index-prefix"].as<std::string>();
|
||||||
}
|
}
|
||||||
|
|
@ -381,6 +690,37 @@ void es_objects_plugin::plugin_initialize(const boost::program_options::variable
|
||||||
if (options.count("es-objects-start-es-after-block")) {
|
if (options.count("es-objects-start-es-after-block")) {
|
||||||
my->_es_objects_start_es_after_block = options["es-objects-start-es-after-block"].as<uint32_t>();
|
my->_es_objects_start_es_after_block = options["es-objects-start-es-after-block"].as<uint32_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
database().applied_block.connect([this](const signed_block &b) {
|
||||||
|
if(b.block_num() == 1 && my->_es_objects_start_es_after_block == 0) {
|
||||||
|
if (!my->genesis())
|
||||||
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Error populating genesis data.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
database().new_objects.connect([this]( const vector<object_id_type>& ids,
|
||||||
|
const flat_set<account_id_type>& impacted_accounts ) {
|
||||||
|
if(!my->index_database(ids, "create"))
|
||||||
|
{
|
||||||
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception,
|
||||||
|
"Error creating object from ES database, we are going to keep trying.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
database().changed_objects.connect([this]( const vector<object_id_type>& ids,
|
||||||
|
const flat_set<account_id_type>& impacted_accounts ) {
|
||||||
|
if(!my->index_database(ids, "update"))
|
||||||
|
{
|
||||||
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception,
|
||||||
|
"Error updating object from ES database, we are going to keep trying.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
database().removed_objects.connect([this](const vector<object_id_type>& ids,
|
||||||
|
const vector<const object*>& objs, const flat_set<account_id_type>& impacted_accounts) {
|
||||||
|
if(!my->index_database(ids, "delete"))
|
||||||
|
{
|
||||||
|
FC_THROW_EXCEPTION(graphene::chain::plugin_exception,
|
||||||
|
"Error deleting object from ES database, we are going to keep trying.");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void es_objects_plugin::plugin_startup()
|
void es_objects_plugin::plugin_startup()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_script.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_script.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
||||||
|
#include <fc/io/raw.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain { namespace bitcoin {
|
namespace graphene { namespace peerplays_sidechain { namespace bitcoin {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <fc/crypto/base58.hpp>
|
#include <fc/crypto/base58.hpp>
|
||||||
|
#include <fc/io/raw.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_script.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_script.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_transaction.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_transaction.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
||||||
|
|
||||||
|
#include <fc/io/raw.hpp>
|
||||||
|
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain { namespace bitcoin {
|
namespace graphene { namespace peerplays_sidechain { namespace bitcoin {
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,10 @@ void peerplays_sidechain_plugin_impl::plugin_initialize(const boost::program_opt
|
||||||
config_ready_son = (options.count("son-id") || options.count("son-ids")) && options.count("peerplays-private-key");
|
config_ready_son = (options.count("son-id") || options.count("son-ids")) && options.count("peerplays-private-key");
|
||||||
if (config_ready_son) {
|
if (config_ready_son) {
|
||||||
LOAD_VALUE_SET(options, "son-id", sons, chain::son_id_type)
|
LOAD_VALUE_SET(options, "son-id", sons, chain::son_id_type)
|
||||||
if (options.count("son-ids"))
|
if (options.count("son-ids")) {
|
||||||
boost::insert(sons, fc::json::from_string(options.at("son-ids").as<string>()).as<vector<chain::son_id_type>>(5));
|
vector<chain::son_id_type> v = fc::json::from_string(options.at("son-ids").as<string>()).as<vector<chain::son_id_type>>(5);
|
||||||
|
sons.insert(v.begin(), v.end());
|
||||||
|
}
|
||||||
config_ready_son = config_ready_son && !sons.empty();
|
config_ready_son = config_ready_son && !sons.empty();
|
||||||
|
|
||||||
#ifndef ENABLE_MULTIPLE_SONS
|
#ifndef ENABLE_MULTIPLE_SONS
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ void sidechain_net_handler::process_proposals() {
|
||||||
|
|
||||||
int32_t op_idx_1 = -1;
|
int32_t op_idx_1 = -1;
|
||||||
chain::operation op_obj_idx_1;
|
chain::operation op_obj_idx_1;
|
||||||
|
(void) op_idx_1;
|
||||||
|
|
||||||
if (po->proposed_transaction.operations.size() >= 2) {
|
if (po->proposed_transaction.operations.size() >= 2) {
|
||||||
op_idx_1 = po->proposed_transaction.operations[1].which();
|
op_idx_1 = po->proposed_transaction.operations[1].which();
|
||||||
|
|
|
||||||
|
|
@ -1005,6 +1005,7 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
|
||||||
|
|
||||||
int32_t op_idx_1 = -1;
|
int32_t op_idx_1 = -1;
|
||||||
chain::operation op_obj_idx_1;
|
chain::operation op_obj_idx_1;
|
||||||
|
(void) op_idx_1;
|
||||||
|
|
||||||
if (po.proposed_transaction.operations.size() >= 2) {
|
if (po.proposed_transaction.operations.size() >= 2) {
|
||||||
op_idx_1 = po.proposed_transaction.operations[1].which();
|
op_idx_1 = po.proposed_transaction.operations[1].which();
|
||||||
|
|
@ -1107,8 +1108,8 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
|
||||||
std::string tx_txid = tx_json.get<std::string>("result.txid");
|
std::string tx_txid = tx_json.get<std::string>("result.txid");
|
||||||
uint32_t tx_confirmations = tx_json.get<uint32_t>("result.confirmations");
|
uint32_t tx_confirmations = tx_json.get<uint32_t>("result.confirmations");
|
||||||
std::string tx_address = "";
|
std::string tx_address = "";
|
||||||
int64_t tx_amount = -1;
|
uint64_t tx_amount = -1;
|
||||||
int64_t tx_vout = -1;
|
uint64_t tx_vout = -1;
|
||||||
|
|
||||||
for (auto &input : tx_json.get_child("result.vout")) {
|
for (auto &input : tx_json.get_child("result.vout")) {
|
||||||
std::string tx_vout_s = input.second.get<std::string>("n");
|
std::string tx_vout_s = input.second.get<std::string>("n");
|
||||||
|
|
@ -1349,6 +1350,7 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() {
|
||||||
const auto &sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
const auto &sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
||||||
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
||||||
[&](const sidechain_address_object &sao) {
|
[&](const sidechain_address_object &sao) {
|
||||||
|
bool retval = true;
|
||||||
if (sao.expires == time_point_sec::maximum()) {
|
if (sao.expires == time_point_sec::maximum()) {
|
||||||
auto usr_pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(sao.deposit_public_key)));
|
auto usr_pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(sao.deposit_public_key)));
|
||||||
|
|
||||||
|
|
@ -1374,13 +1376,14 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() {
|
||||||
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
||||||
if (plugin.app().p2p_node())
|
if (plugin.app().p2p_node())
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
return true;
|
retval = true;
|
||||||
} catch (fc::exception &e) {
|
} catch (fc::exception &e) {
|
||||||
elog("Sending proposal for deposit sidechain transaction create operation failed with exception ${e}", ("e", e.what()));
|
elog("Sending proposal for deposit sidechain transaction create operation failed with exception ${e}", ("e", e.what()));
|
||||||
return false;
|
retval = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return retval;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1658,11 +1661,11 @@ std::string sidechain_net_handler_bitcoin::create_withdrawal_transaction(const s
|
||||||
std::string pw_address = json.get<std::string>("address");
|
std::string pw_address = json.get<std::string>("address");
|
||||||
std::string redeem_script = json.get<std::string>("redeemScript");
|
std::string redeem_script = json.get<std::string>("redeemScript");
|
||||||
|
|
||||||
uint64_t fee_rate = bitcoin_client->estimatesmartfee();
|
int64_t fee_rate = bitcoin_client->estimatesmartfee();
|
||||||
uint64_t min_fee_rate = 1000;
|
int64_t min_fee_rate = 1000;
|
||||||
fee_rate = std::max(fee_rate, min_fee_rate);
|
fee_rate = std::max(fee_rate, min_fee_rate);
|
||||||
|
|
||||||
uint64_t total_amount = 0;
|
int64_t total_amount = 0;
|
||||||
std::vector<btc_txout> inputs = bitcoin_client->listunspent_by_address_and_amount(pw_address, 0);
|
std::vector<btc_txout> inputs = bitcoin_client->listunspent_by_address_and_amount(pw_address, 0);
|
||||||
|
|
||||||
if (inputs.size() == 0) {
|
if (inputs.size() == 0) {
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ void sidechain_net_handler_peerplays::process_sidechain_addresses() {
|
||||||
const auto &sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
const auto &sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain);
|
||||||
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
||||||
[&](const sidechain_address_object &sao) {
|
[&](const sidechain_address_object &sao) {
|
||||||
|
bool retval = true;
|
||||||
if (sao.expires == time_point_sec::maximum()) {
|
if (sao.expires == time_point_sec::maximum()) {
|
||||||
if (sao.deposit_address == "") {
|
if (sao.deposit_address == "") {
|
||||||
sidechain_address_update_operation op;
|
sidechain_address_update_operation op;
|
||||||
|
|
@ -150,13 +151,14 @@ void sidechain_net_handler_peerplays::process_sidechain_addresses() {
|
||||||
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
||||||
if (plugin.app().p2p_node())
|
if (plugin.app().p2p_node())
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
return true;
|
retval = true;
|
||||||
} catch (fc::exception &e) {
|
} catch (fc::exception &e) {
|
||||||
elog("Sending transaction for update deposit address operation failed with exception ${e}", ("e", e.what()));
|
elog("Sending transaction for update deposit address operation failed with exception ${e}", ("e", e.what()));
|
||||||
return false;
|
retval = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return retval;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,10 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m
|
||||||
ilog("witness plugin: plugin_initialize() begin");
|
ilog("witness plugin: plugin_initialize() begin");
|
||||||
_options = &options;
|
_options = &options;
|
||||||
LOAD_VALUE_SET(options, "witness-id", _witnesses, chain::witness_id_type)
|
LOAD_VALUE_SET(options, "witness-id", _witnesses, chain::witness_id_type)
|
||||||
if (options.count("witness-ids"))
|
if (options.count("witness-ids")) {
|
||||||
boost::insert(_witnesses, fc::json::from_string(options.at("witness-ids").as<string>()).as<vector<chain::witness_id_type>>( 5 ));
|
vector<chain::witness_id_type> v = fc::json::from_string(options.at("witness-ids").as<string>()).as<vector<chain::witness_id_type>>( 5 );
|
||||||
|
_witnesses.insert(v.begin(), v.end());
|
||||||
|
}
|
||||||
|
|
||||||
if( options.count("private-key") )
|
if( options.count("private-key") )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5610,8 +5610,15 @@ signed_transaction wallet_api::sell( string seller_account,
|
||||||
double amount,
|
double amount,
|
||||||
bool broadcast )
|
bool broadcast )
|
||||||
{
|
{
|
||||||
return my->sell_asset( seller_account, std::to_string( amount ), base,
|
std::stringstream ss;
|
||||||
std::to_string( rate * amount ), quote, 0, false, broadcast );
|
ss.str(std::string());
|
||||||
|
ss << std::noshowpoint << amount;
|
||||||
|
std::string amount_to_sell = ss.str();
|
||||||
|
ss.str(std::string());
|
||||||
|
ss << std::noshowpoint << rate * amount;
|
||||||
|
std::string min_to_receive = ss.str();
|
||||||
|
return my->sell_asset( seller_account, amount_to_sell, base,
|
||||||
|
min_to_receive, quote, 0, false, broadcast );
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::buy( string buyer_account,
|
signed_transaction wallet_api::buy( string buyer_account,
|
||||||
|
|
@ -5621,8 +5628,15 @@ signed_transaction wallet_api::buy( string buyer_account,
|
||||||
double amount,
|
double amount,
|
||||||
bool broadcast )
|
bool broadcast )
|
||||||
{
|
{
|
||||||
return my->sell_asset( buyer_account, std::to_string( rate * amount ), quote,
|
std::stringstream ss;
|
||||||
std::to_string( amount ), base, 0, false, broadcast );
|
ss.str(std::string());
|
||||||
|
ss << std::noshowpoint << rate * amount;
|
||||||
|
std::string amount_to_sell = ss.str();
|
||||||
|
ss.str(std::string());
|
||||||
|
ss << std::noshowpoint << amount;
|
||||||
|
std::string min_to_receive = ss.str();
|
||||||
|
return my->sell_asset( buyer_account, amount_to_sell, quote,
|
||||||
|
min_to_receive, base, 0, false, broadcast );
|
||||||
}
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell,
|
signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -201,9 +201,39 @@ cli_fixture::~cli_fixture()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cli_fixture::generate_blocks(fc::time_point_sec timestamp, bool miss_intermediate_blocks, uint32_t skip)
|
||||||
|
{
|
||||||
|
auto db = app1->chain_database();
|
||||||
|
|
||||||
|
if( miss_intermediate_blocks )
|
||||||
|
{
|
||||||
|
generate_block(skip);
|
||||||
|
auto slots_to_miss = db->get_slot_at_time(timestamp);
|
||||||
|
if( slots_to_miss <= 1 )
|
||||||
|
return;
|
||||||
|
--slots_to_miss;
|
||||||
|
generate_block(skip, fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))), slots_to_miss);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while( db->head_block_time() < timestamp )
|
||||||
|
generate_block(skip);
|
||||||
|
}
|
||||||
|
|
||||||
|
signed_block cli_fixture::generate_block(uint32_t skip, const fc::ecc::private_key& key, int miss_blocks)
|
||||||
|
{
|
||||||
|
skip |= database::skip_undo_history_check;
|
||||||
|
// skip == ~0 will skip checks specified in database::validation_steps
|
||||||
|
auto db = app1->chain_database();
|
||||||
|
auto block = db->generate_block(db->get_slot_time(miss_blocks + 1),
|
||||||
|
db->get_scheduled_witness(miss_blocks + 1),
|
||||||
|
key, skip);
|
||||||
|
db->clear_pending();
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
bool cli_fixture::generate_maintenance_block() {
|
bool cli_fixture::generate_maintenance_block() {
|
||||||
try {
|
try {
|
||||||
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
|
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
||||||
uint32_t skip = ~database::skip_fork_db;
|
uint32_t skip = ~database::skip_fork_db;
|
||||||
auto db = app1->chain_database();
|
auto db = app1->chain_database();
|
||||||
auto maint_time = db->get_dynamic_global_properties().next_maintenance_time;
|
auto maint_time = db->get_dynamic_global_properties().next_maintenance_time;
|
||||||
|
|
@ -219,27 +249,6 @@ bool cli_fixture::generate_maintenance_block() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cli_fixture::generate_block()
|
|
||||||
{
|
|
||||||
graphene::chain::signed_block returned_block;
|
|
||||||
return generate_block(returned_block);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cli_fixture::generate_block(graphene::chain::signed_block& returned_block)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan")));
|
|
||||||
auto db = app1->chain_database();
|
|
||||||
returned_block = db->generate_block( db->get_slot_time(1),
|
|
||||||
db->get_scheduled_witness(1),
|
|
||||||
committee_key,
|
|
||||||
database::skip_nothing );
|
|
||||||
return true;
|
|
||||||
} catch (exception &e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cli_fixture::init_nathan()
|
void cli_fixture::init_nathan()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -254,7 +263,7 @@ void cli_fixture::init_nathan()
|
||||||
import_txs = con.wallet_api_ptr->import_balance("nathan", nathan_keys, true);
|
import_txs = con.wallet_api_ptr->import_balance("nathan", nathan_keys, true);
|
||||||
nathan_acct_before_upgrade = con.wallet_api_ptr->get_account("nathan");
|
nathan_acct_before_upgrade = con.wallet_api_ptr->get_account("nathan");
|
||||||
|
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// upgrade nathan
|
// upgrade nathan
|
||||||
BOOST_TEST_MESSAGE("Upgrading Nathan to LTM");
|
BOOST_TEST_MESSAGE("Upgrading Nathan to LTM");
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,12 @@ struct cli_fixture
|
||||||
cli_fixture();
|
cli_fixture();
|
||||||
~cli_fixture();
|
~cli_fixture();
|
||||||
|
|
||||||
///////////
|
signed_block generate_block(uint32_t skip = ~0,
|
||||||
/// Send a block to the db
|
const fc::ecc::private_key& key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))),
|
||||||
/// @param returned_block the signed block
|
int miss_blocks = 0);
|
||||||
/// @returns true on success
|
|
||||||
///////////
|
void generate_blocks(fc::time_point_sec timestamp, bool miss_intermediate_blocks = true, uint32_t skip = ~0);
|
||||||
bool generate_block(graphene::chain::signed_block& returned_block);
|
|
||||||
bool generate_block();
|
|
||||||
///////////
|
///////////
|
||||||
/// @brief Skip intermediate blocks, and generate a maintenance block
|
/// @brief Skip intermediate blocks, and generate a maintenance block
|
||||||
/// @returns true on success
|
/// @returns true on success
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE( create_new_account )
|
||||||
BOOST_CHECK(con.wallet_api_ptr->import_key("jmjatlanta", bki.wif_priv_key));
|
BOOST_CHECK(con.wallet_api_ptr->import_key("jmjatlanta", bki.wif_priv_key));
|
||||||
con.wallet_api_ptr->save_wallet_file(con.wallet_filename);
|
con.wallet_api_ptr->save_wallet_file(con.wallet_filename);
|
||||||
|
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
fc::usleep( fc::seconds(1) );
|
fc::usleep( fc::seconds(1) );
|
||||||
|
|
||||||
// attempt to give jmjatlanta some peerplays
|
// attempt to give jmjatlanta some peerplays
|
||||||
|
|
@ -112,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture )
|
||||||
signed_transaction vote_witness1_tx = con.wallet_api_ptr->vote_for_witness("jmjatlanta", "init1", true, true);
|
signed_transaction vote_witness1_tx = con.wallet_api_ptr->vote_for_witness("jmjatlanta", "init1", true, true);
|
||||||
|
|
||||||
// generate a block to get things started
|
// generate a block to get things started
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
// wait for a maintenance interval
|
// wait for a maintenance interval
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE( account_history_pagination )
|
||||||
"1.3.0", "Here are some CORE token for your new account", true);
|
"1.3.0", "Here are some CORE token for your new account", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// now get account history and make sure everything is there (and no duplicates)
|
// now get account history and make sure everything is there (and no duplicates)
|
||||||
std::vector<graphene::wallet::operation_detail> history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300);
|
std::vector<graphene::wallet::operation_detail> history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300);
|
||||||
|
|
@ -489,7 +489,7 @@ BOOST_FIXTURE_TEST_CASE( saving_keys_wallet_test, cli_fixture )
|
||||||
graphene::wallet::plain_keys pk = decrypt_keys( "supersecret", wallet.cipher_keys );
|
graphene::wallet::plain_keys pk = decrypt_keys( "supersecret", wallet.cipher_keys );
|
||||||
BOOST_CHECK( pk.keys.size() == 1 ); // nathan key
|
BOOST_CHECK( pk.keys.size() == 1 ); // nathan key
|
||||||
|
|
||||||
BOOST_CHECK( generate_block() );
|
generate_block();
|
||||||
fc::usleep( fc::seconds(1) );
|
fc::usleep( fc::seconds(1) );
|
||||||
|
|
||||||
wallet = fc::json::from_file( path ).as<graphene::wallet::wallet_data>( 2 * GRAPHENE_MAX_NESTED_OBJECTS );
|
wallet = fc::json::from_file( path ).as<graphene::wallet::wallet_data>( 2 * GRAPHENE_MAX_NESTED_OBJECTS );
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <graphene/chain/config.hpp>
|
||||||
|
#include <graphene/chain/hardfork.hpp>
|
||||||
|
|
||||||
class son_test_helper
|
class son_test_helper
|
||||||
{
|
{
|
||||||
cli_fixture& fixture_;
|
cli_fixture& fixture_;
|
||||||
|
|
@ -36,6 +39,8 @@ public:
|
||||||
fixture_(fixture)
|
fixture_(fixture)
|
||||||
{
|
{
|
||||||
fixture_.init_nathan();
|
fixture_.init_nathan();
|
||||||
|
fixture_.generate_blocks(HARDFORK_SON_TIME);
|
||||||
|
fixture_.generate_block();
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_son(const std::string& account_name, const std::string& son_url,
|
void create_son(const std::string& account_name, const std::string& son_url,
|
||||||
|
|
@ -65,7 +70,7 @@ public:
|
||||||
"nathan", account_name, "65000", "1.3.0", "Here are some CORE token for your new account", true
|
"nathan", account_name, "65000", "1.3.0", "Here are some CORE token for your new account", true
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOST_CHECK(fixture_.generate_block());
|
fixture_.generate_block();
|
||||||
|
|
||||||
// upgrade son account
|
// upgrade son account
|
||||||
BOOST_TEST_MESSAGE("Upgrading son account to LTM");
|
BOOST_TEST_MESSAGE("Upgrading son account to LTM");
|
||||||
|
|
@ -75,16 +80,16 @@ public:
|
||||||
// verify that the upgrade was successful
|
// verify that the upgrade was successful
|
||||||
BOOST_CHECK(son_account.is_lifetime_member());
|
BOOST_CHECK(son_account.is_lifetime_member());
|
||||||
|
|
||||||
BOOST_CHECK(fixture_.generate_block());
|
fixture_.generate_block();
|
||||||
|
|
||||||
// create deposit vesting
|
// create deposit vesting
|
||||||
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name,
|
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name,
|
||||||
"50", "1.3.0", vesting_balance_type::son, true);
|
"50", "1.3.0", vesting_balance_type::son, true);
|
||||||
BOOST_CHECK(fixture_.generate_block());
|
fixture_.generate_block();
|
||||||
|
|
||||||
// create pay_vb vesting
|
// create pay_vb vesting
|
||||||
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name, "1", "1.3.0", vesting_balance_type::normal, true);
|
fixture_.con.wallet_api_ptr->create_vesting_balance(account_name, "1", "1.3.0", vesting_balance_type::normal, true);
|
||||||
BOOST_CHECK(fixture_.generate_block());
|
fixture_.generate_block();
|
||||||
|
|
||||||
// check deposits are here
|
// check deposits are here
|
||||||
auto deposits = fixture_.con.wallet_api_ptr->get_vesting_balances(account_name);
|
auto deposits = fixture_.con.wallet_api_ptr->get_vesting_balances(account_name);
|
||||||
|
|
@ -169,10 +174,11 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
|
||||||
|
|
||||||
// update SON signing key
|
// update SON signing key
|
||||||
sidechain_public_keys.clear();
|
sidechain_public_keys.clear();
|
||||||
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated2", "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG", sidechain_public_keys, true);
|
std::string new_key = GRAPHENE_ADDRESS_PREFIX + std::string("6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG");
|
||||||
|
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated2", new_key, sidechain_public_keys, true);
|
||||||
son_data = con.wallet_api_ptr->get_son("sonmember");
|
son_data = con.wallet_api_ptr->get_son("sonmember");
|
||||||
BOOST_CHECK(son_data.url == "http://sonmember_updated2");
|
BOOST_CHECK(son_data.url == "http://sonmember_updated2");
|
||||||
BOOST_CHECK(std::string(son_data.signing_key) == "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG");
|
BOOST_CHECK(std::string(son_data.signing_key) == new_key);
|
||||||
|
|
||||||
} catch( fc::exception& e ) {
|
} catch( fc::exception& e ) {
|
||||||
edump((e.to_detail_string()));
|
edump((e.to_detail_string()));
|
||||||
|
|
@ -421,7 +427,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
con.wallet_api_ptr->create_vesting_balance("nathan", "1000", "1.3.0", vesting_balance_type::gpos, true);
|
||||||
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 2, true);
|
rejected, 2, true);
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
BOOST_CHECK(generate_maintenance_block());
|
BOOST_CHECK(generate_maintenance_block());
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
|
|
@ -461,7 +467,7 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
|
||||||
rejected.push_back("son1accnt");
|
rejected.push_back("son1accnt");
|
||||||
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted,
|
||||||
rejected, 1, true), fc::exception);
|
rejected, 1, true), fc::exception);
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// Verify the votes
|
// Verify the votes
|
||||||
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
son1_obj = con.wallet_api_ptr->get_son("son1account");
|
||||||
|
|
@ -675,7 +681,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
||||||
|
|
||||||
// put SON in maintenance mode
|
// put SON in maintenance mode
|
||||||
con.wallet_api_ptr->request_son_maintenance(name, true);
|
con.wallet_api_ptr->request_son_maintenance(name, true);
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// check SON is in request_maintenance
|
// check SON is in request_maintenance
|
||||||
son_obj = con.wallet_api_ptr->get_son(name);
|
son_obj = con.wallet_api_ptr->get_son(name);
|
||||||
|
|
@ -683,7 +689,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
||||||
|
|
||||||
// restore SON activity
|
// restore SON activity
|
||||||
con.wallet_api_ptr->cancel_request_son_maintenance(name, true);
|
con.wallet_api_ptr->cancel_request_son_maintenance(name, true);
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// check SON is active
|
// check SON is active
|
||||||
son_obj = con.wallet_api_ptr->get_son(name);
|
son_obj = con.wallet_api_ptr->get_son(name);
|
||||||
|
|
@ -691,7 +697,7 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
||||||
|
|
||||||
// put SON in maintenance mode
|
// put SON in maintenance mode
|
||||||
con.wallet_api_ptr->request_son_maintenance(name, true);
|
con.wallet_api_ptr->request_son_maintenance(name, true);
|
||||||
BOOST_CHECK(generate_block());
|
generate_block();
|
||||||
|
|
||||||
// check SON is in request_maintenance
|
// check SON is in request_maintenance
|
||||||
son_obj = con.wallet_api_ptr->get_son(name);
|
son_obj = con.wallet_api_ptr->get_son(name);
|
||||||
|
|
|
||||||
|
|
@ -33,110 +33,110 @@ using namespace graphene::chain;
|
||||||
#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||||
create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
|
create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const sport_object& ice_hockey = *db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin(); \
|
const sport_id_type ice_hockey_id = (*db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \
|
create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_group_object& nhl = *db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin(); \
|
const event_group_id_type nhl_id = (*db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \
|
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_object& capitals_vs_blackhawks = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
const event_id_type capitals_vs_blackhawks_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \
|
create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_rules_object& betting_market_rules = *db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_rules_id_type betting_market_rules_id = (*db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& moneyline_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type moneyline_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type& blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
(void)capitals_win_market; (void)blackhawks_win_market;
|
(void)capitals_win_market_id; (void)blackhawks_win_market_id;
|
||||||
|
|
||||||
// create the basic betting market, plus groups for the first, second, and third period results
|
// create the basic betting market, plus groups for the first, second, and third period results
|
||||||
#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||||
CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \
|
||||||
create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type first_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& first_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type first_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type first_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
(void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \
|
(void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \
|
||||||
\
|
\
|
||||||
create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type second_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& second_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type second_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type second_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
(void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \
|
(void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \
|
||||||
\
|
\
|
||||||
create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \
|
create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type third_period_result_betting_markets_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \
|
create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& third_period_capitals_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type third_period_capitals_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \
|
create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type third_period_blackhawks_win_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
(void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market;
|
(void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id;
|
||||||
|
|
||||||
#define CREATE_TENNIS_BETTING_MARKET() \
|
#define CREATE_TENNIS_BETTING_MARKET() \
|
||||||
create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \
|
create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_rules_object& tennis_rules = *db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_rules_id_type tennis_rules_id = (*db.get_index_type<betting_market_rules_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_sport({{"en", "Tennis"}}); \
|
create_sport({{"en", "Tennis"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const sport_object& tennis = *db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin(); \
|
const sport_id_type tennis_id = (*db.get_index_type<sport_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event_group({{"en", "Wimbledon"}}, tennis.id); \
|
create_event_group({{"en", "Wimbledon"}}, tennis_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_group_object& wimbledon = *db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin(); \
|
const event_group_id_type wimbledon_id = (*db.get_index_type<event_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \
|
create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_object& berdych_vs_federer = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
const event_id_type berdych_vs_federer_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \
|
create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_object& cilic_vs_querrey = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
const event_id_type& cilic_vs_querrey_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \
|
create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type moneyline_berdych_vs_federer_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \
|
create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type moneyline_cilic_vs_querrey_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \
|
create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& berdych_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type berdych_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \
|
create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& federer_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type federer_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \
|
create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& cilic_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type cilic_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\
|
create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& querrey_wins_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type querrey_wins_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \
|
create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_object& cilic_vs_federer = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
const event_id_type& cilic_vs_federer_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \
|
create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_group_id_type moneyline_cilic_vs_federer_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \
|
create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& federer_wins_final_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type federer_wins_final_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \
|
create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const betting_market_object& cilic_wins_final_market = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin(); \
|
const betting_market_id_type cilic_wins_final_market_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
(void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market;
|
(void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id;
|
||||||
|
|
||||||
// set up a fixture that places a series of two matched bets, we'll use this fixture to verify
|
// set up a fixture that places a series of two matched bets, we'll use this fixture to verify
|
||||||
// the result in all three possible outcomes
|
// the result in all three possible outcomes
|
||||||
|
|
@ -155,19 +155,18 @@ struct simple_bet_test_fixture : database_fixture {
|
||||||
transfer(account_id_type(), bob_id, asset(10000));
|
transfer(account_id_type(), bob_id, asset(10000));
|
||||||
|
|
||||||
// place bets at 10:1
|
// place bets at 10:1
|
||||||
place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
// reverse positions at 1:1
|
// reverse positions at 1:1
|
||||||
place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
capitals_win_betting_market_id = capitals_win_market.id;
|
capitals_win_betting_market_id = capitals_win_market_id;
|
||||||
blackhawks_win_betting_market_id = blackhawks_win_market.id;
|
blackhawks_win_betting_market_id = blackhawks_win_market_id;
|
||||||
moneyline_betting_markets_id = moneyline_betting_markets.id;
|
|
||||||
|
|
||||||
// close betting to prepare for the next operation which will be grading or cancel
|
// close betting to prepare for the next operation which will be grading or cancel
|
||||||
update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||||
generate_blocks(1);
|
generate_blocks(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,10 @@
|
||||||
|
|
||||||
using namespace graphene::chain::test;
|
using namespace graphene::chain::test;
|
||||||
|
|
||||||
|
//redefining parameters here to as per updated TESTNET parameters to verify unit test cases
|
||||||
uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP = 1431700002;
|
uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP = 1431700002;
|
||||||
|
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
@ -202,20 +204,28 @@ database_fixture::database_fixture()
|
||||||
}
|
}
|
||||||
|
|
||||||
database_fixture::~database_fixture()
|
database_fixture::~database_fixture()
|
||||||
{ try {
|
{
|
||||||
// If we're unwinding due to an exception, don't do any more checks.
|
try {
|
||||||
// This way, boost test's last checkpoint tells us approximately where the error was.
|
// If we're unwinding due to an exception, don't do any more checks.
|
||||||
if( !std::uncaught_exception() )
|
// This way, boost test's last checkpoint tells us approximately where the error was.
|
||||||
{
|
if( !std::uncaught_exception() )
|
||||||
verify_asset_supplies(db);
|
{
|
||||||
verify_account_history_plugin_index();
|
verify_asset_supplies(db);
|
||||||
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
|
verify_account_history_plugin_index();
|
||||||
}
|
BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing );
|
||||||
|
}
|
||||||
|
|
||||||
if( data_dir )
|
if( data_dir )
|
||||||
db.close();
|
db.close();
|
||||||
return;
|
return;
|
||||||
} FC_CAPTURE_AND_RETHROW() }
|
} catch (fc::exception& ex) {
|
||||||
|
BOOST_FAIL( std::string("fc::exception in ~database_fixture: ") + ex.to_detail_string() );
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
BOOST_FAIL( std::string("std::exception in ~database_fixture:") + e.what() );
|
||||||
|
} catch (...) {
|
||||||
|
BOOST_FAIL( "Uncaught exception in ~database_fixture" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fc::ecc::private_key database_fixture::generate_private_key(string seed)
|
fc::ecc::private_key database_fixture::generate_private_key(string seed)
|
||||||
{
|
{
|
||||||
|
|
@ -235,8 +245,9 @@ string database_fixture::generate_anon_acct_name()
|
||||||
void database_fixture::verify_asset_supplies( const database& db )
|
void database_fixture::verify_asset_supplies( const database& db )
|
||||||
{
|
{
|
||||||
//wlog("*** Begin asset supply verification ***");
|
//wlog("*** Begin asset supply verification ***");
|
||||||
const asset_dynamic_data_object& core_asset_data = db.get_core_asset().dynamic_asset_data_id(db);
|
// It seems peerplays by default DO have core fee pool in genesis so commenting this out
|
||||||
BOOST_CHECK(core_asset_data.fee_pool == 0);
|
//const asset_dynamic_data_object& core_asset_data = db.get_core_asset().dynamic_asset_data_id(db);
|
||||||
|
//BOOST_CHECK(core_asset_data.fee_pool == 0);
|
||||||
|
|
||||||
const auto& statistics_index = db.get_index_type<account_stats_index>().indices();
|
const auto& statistics_index = db.get_index_type<account_stats_index>().indices();
|
||||||
const auto& balance_index = db.get_index_type<account_balance_index>().indices();
|
const auto& balance_index = db.get_index_type<account_balance_index>().indices();
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,9 @@ extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP;
|
||||||
|
|
||||||
#define PREP_ACTOR(name) \
|
#define PREP_ACTOR(name) \
|
||||||
fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE(name)); \
|
fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE(name)); \
|
||||||
public_key_type name ## _public_key = name ## _private_key.get_public_key();
|
public_key_type name ## _public_key = name ## _private_key.get_public_key(); \
|
||||||
|
(void) name ## _private_key; \
|
||||||
|
(void) name ## _public_key;
|
||||||
|
|
||||||
#define ACTOR(name) \
|
#define ACTOR(name) \
|
||||||
PREP_ACTOR(name) \
|
PREP_ACTOR(name) \
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
#include <fc/io/raw.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_transaction.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_transaction.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/serialize.hpp>
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/utils.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/utils.hpp>
|
||||||
|
|
|
||||||
|
|
@ -524,17 +524,17 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
||||||
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
|
CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0);
|
||||||
|
|
||||||
// place bets at 10:1
|
// place bets at 10:1
|
||||||
place_bet(ath.paula_id, capitals_win_market.id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.paula_id, capitals_win_market_id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(ath.penny_id, capitals_win_market.id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.penny_id, capitals_win_market_id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
// reverse positions at 1:1
|
// reverse positions at 1:1
|
||||||
place_bet(ath.paula_id, capitals_win_market.id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.paula_id, capitals_win_market_id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(ath.penny_id, capitals_win_market.id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.penny_id, capitals_win_market_id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||||
resolve_betting_market_group(moneyline_betting_markets.id,
|
resolve_betting_market_group(moneyline_betting_markets_id,
|
||||||
{{capitals_win_market.id, betting_market_resolution_type::win},
|
{{capitals_win_market_id, betting_market_resolution_type::win},
|
||||||
{blackhawks_win_market.id, betting_market_resolution_type::not_win}});
|
{blackhawks_win_market_id, betting_market_resolution_type::not_win}});
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage();
|
uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage();
|
||||||
|
|
@ -559,31 +559,31 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
||||||
issue_uia( ath.paula_id, asset( 1000000, btc_id ) );
|
issue_uia( ath.paula_id, asset( 1000000, btc_id ) );
|
||||||
issue_uia( ath.petra_id, asset( 1000000, btc_id ) );
|
issue_uia( ath.petra_id, asset( 1000000, btc_id ) );
|
||||||
|
|
||||||
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \
|
create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \
|
||||||
generate_blocks(1); \
|
generate_blocks(1); \
|
||||||
const event_object& capitals_vs_blackhawks2 = *db.get_index_type<event_object_index>().indices().get<by_id>().rbegin(); \
|
const event_id_type capitals_vs_blackhawks2_id = (*db.get_index_type<event_object_index>().indices().get<by_id>().rbegin()).id; \
|
||||||
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules.id, btc_id, false, 0);
|
create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2_id, betting_market_rules_id, btc_id, false, 0);
|
||||||
generate_blocks(1);
|
generate_blocks(1);
|
||||||
const betting_market_group_object& moneyline_betting_markets2 = *db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin();
|
const betting_market_group_id_type moneyline_betting_markets2_id = (*db.get_index_type<betting_market_group_object_index>().indices().get<by_id>().rbegin()).id;
|
||||||
create_betting_market(moneyline_betting_markets2.id, {{"en", "Washington Capitals win"}});
|
create_betting_market(moneyline_betting_markets2_id, {{"en", "Washington Capitals win"}});
|
||||||
generate_blocks(1);
|
generate_blocks(1);
|
||||||
const betting_market_object& capitals_win_market2 = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin();
|
const betting_market_id_type capitals_win_market2_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id;
|
||||||
create_betting_market(moneyline_betting_markets2.id, {{"en", "Chicago Blackhawks win"}});
|
create_betting_market(moneyline_betting_markets2_id, {{"en", "Chicago Blackhawks win"}});
|
||||||
generate_blocks(1);
|
generate_blocks(1);
|
||||||
const betting_market_object& blackhawks_win_market2 = *db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin();
|
const betting_market_id_type blackhawks_win_market2_id = (*db.get_index_type<betting_market_object_index>().indices().get<by_id>().rbegin()).id;
|
||||||
|
|
||||||
// place bets at 10:1
|
// place bets at 10:1
|
||||||
place_bet(ath.paula_id, capitals_win_market2.id, bet_type::back, asset(10000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.paula_id, capitals_win_market2_id, bet_type::back, asset(10000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(ath.petra_id, capitals_win_market2.id, bet_type::lay, asset(100000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.petra_id, capitals_win_market2_id, bet_type::lay, asset(100000, btc_id), 11 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
// reverse positions at 1:1
|
// reverse positions at 1:1
|
||||||
place_bet(ath.paula_id, capitals_win_market2.id, bet_type::lay, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.paula_id, capitals_win_market2_id, bet_type::lay, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
place_bet(ath.petra_id, capitals_win_market2.id, bet_type::back, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
place_bet(ath.petra_id, capitals_win_market2_id, bet_type::back, asset(110000, btc_id), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
|
||||||
|
|
||||||
update_betting_market_group(moneyline_betting_markets2.id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
update_betting_market_group(moneyline_betting_markets2_id, graphene::chain::keywords::_status = betting_market_group_status::closed);
|
||||||
resolve_betting_market_group(moneyline_betting_markets2.id,
|
resolve_betting_market_group(moneyline_betting_markets2_id,
|
||||||
{{capitals_win_market2.id, betting_market_resolution_type::not_win},
|
{{capitals_win_market2_id, betting_market_resolution_type::not_win},
|
||||||
{blackhawks_win_market2.id, betting_market_resolution_type::win}});
|
{blackhawks_win_market2_id, betting_market_resolution_type::win}});
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
rake_value = (-10000 + 0 - 110000 + 220000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100;
|
rake_value = (-10000 + 0 - 110000 + 220000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ genesis_state_type make_genesis() {
|
||||||
|
|
||||||
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
||||||
genesis_state.initial_active_witnesses = 10;
|
genesis_state.initial_active_witnesses = 10;
|
||||||
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
|
for( uint64_t i = 0; i < genesis_state.initial_active_witnesses; ++i )
|
||||||
{
|
{
|
||||||
auto name = "init"+fc::to_string(i);
|
auto name = "init"+fc::to_string(i);
|
||||||
genesis_state.initial_accounts.emplace_back(name,
|
genesis_state.initial_accounts.emplace_back(name,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ BOOST_AUTO_TEST_CASE( confidential_test )
|
||||||
|
|
||||||
auto InB1 = fc::sha256::hash("InB1");
|
auto InB1 = fc::sha256::hash("InB1");
|
||||||
auto InB2 = fc::sha256::hash("InB2");
|
auto InB2 = fc::sha256::hash("InB2");
|
||||||
auto OutB = fc::sha256::hash("InB2");
|
|
||||||
auto nonce1 = fc::sha256::hash("nonce");
|
auto nonce1 = fc::sha256::hash("nonce");
|
||||||
auto nonce2 = fc::sha256::hash("nonce2");
|
auto nonce2 = fc::sha256::hash("nonce2");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE( merge_test )
|
||||||
try {
|
try {
|
||||||
database db;
|
database db;
|
||||||
auto ses = db._undo_db.start_undo_session();
|
auto ses = db._undo_db.start_undo_session();
|
||||||
const auto& bal_obj1 = db.create<account_balance_object>( [&]( account_balance_object& obj ){
|
db.create<account_balance_object>( [&]( account_balance_object& obj ){
|
||||||
obj.balance = 42;
|
obj.balance = 42;
|
||||||
});
|
});
|
||||||
ses.merge();
|
ses.merge();
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,6 @@ BOOST_AUTO_TEST_CASE( test_basic_dividend_distribution )
|
||||||
const account_object& alice = get_account("alice");
|
const account_object& alice = get_account("alice");
|
||||||
const account_object& bob = get_account("bob");
|
const account_object& bob = get_account("bob");
|
||||||
const account_object& carol = get_account("carol");
|
const account_object& carol = get_account("carol");
|
||||||
const account_object& dave = get_account("dave");
|
|
||||||
const account_object& frank = get_account("frank");
|
|
||||||
const auto& test_asset_object = get_asset("TESTB");
|
const auto& test_asset_object = get_asset("TESTB");
|
||||||
|
|
||||||
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
||||||
|
|
@ -379,7 +377,6 @@ BOOST_AUTO_TEST_CASE( test_basic_dividend_distribution_to_core_asset )
|
||||||
const account_object& bob = get_account("bob");
|
const account_object& bob = get_account("bob");
|
||||||
const account_object& carol = get_account("carol");
|
const account_object& carol = get_account("carol");
|
||||||
const account_object& dave = get_account("dave");
|
const account_object& dave = get_account("dave");
|
||||||
const account_object& frank = get_account("frank");
|
|
||||||
const auto& test_asset_object = get_asset("TESTB");
|
const auto& test_asset_object = get_asset("TESTB");
|
||||||
|
|
||||||
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
||||||
|
|
@ -513,28 +510,6 @@ BOOST_AUTO_TEST_CASE( test_basic_dividend_distribution_to_core_asset )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( test_dividend_distribution_interval )
|
|
||||||
{
|
|
||||||
using namespace graphene;
|
|
||||||
try {
|
|
||||||
INVOKE( create_dividend_uia );
|
|
||||||
|
|
||||||
const auto& dividend_holder_asset_object = get_asset("DIVIDEND");
|
|
||||||
const auto& dividend_data = dividend_holder_asset_object.dividend_data(db);
|
|
||||||
const account_object& dividend_distribution_account = dividend_data.dividend_distribution_account(db);
|
|
||||||
const account_object& alice = get_account("alice");
|
|
||||||
const account_object& bob = get_account("bob");
|
|
||||||
const account_object& carol = get_account("carol");
|
|
||||||
const account_object& dave = get_account("dave");
|
|
||||||
const account_object& frank = get_account("frank");
|
|
||||||
const auto& test_asset_object = get_asset("TESTB");
|
|
||||||
} catch(fc::exception& e) {
|
|
||||||
edump((e.to_detail_string()));
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( check_dividend_corner_cases )
|
BOOST_AUTO_TEST_CASE( check_dividend_corner_cases )
|
||||||
{
|
{
|
||||||
using namespace graphene;
|
using namespace graphene;
|
||||||
|
|
@ -547,8 +522,6 @@ BOOST_AUTO_TEST_CASE( check_dividend_corner_cases )
|
||||||
const account_object& alice = get_account("alice");
|
const account_object& alice = get_account("alice");
|
||||||
const account_object& bob = get_account("bob");
|
const account_object& bob = get_account("bob");
|
||||||
const account_object& carol = get_account("carol");
|
const account_object& carol = get_account("carol");
|
||||||
const account_object& dave = get_account("dave");
|
|
||||||
const account_object& frank = get_account("frank");
|
|
||||||
const auto& test_asset_object = get_asset("TESTB");
|
const auto& test_asset_object = get_asset("TESTB");
|
||||||
|
|
||||||
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
auto issue_asset_to_account = [&](const asset_object& asset_to_issue, const account_object& destination_account, int64_t amount_to_issue)
|
||||||
|
|
@ -570,16 +543,6 @@ BOOST_AUTO_TEST_CASE( check_dividend_corner_cases )
|
||||||
BOOST_CHECK_EQUAL(pending_balance, expected_balance);
|
BOOST_CHECK_EQUAL(pending_balance, expected_balance);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto reserve_asset_from_account = [&](const asset_object& asset_to_reserve, const account_object& from_account, int64_t amount_to_reserve)
|
|
||||||
{
|
|
||||||
asset_reserve_operation reserve_op;
|
|
||||||
reserve_op.payer = from_account.id;
|
|
||||||
reserve_op.amount_to_reserve = asset(amount_to_reserve, asset_to_reserve.id);
|
|
||||||
trx.operations.push_back(reserve_op);
|
|
||||||
set_expiration(db, trx);
|
|
||||||
PUSH_TX( db, trx, ~0 );
|
|
||||||
trx.operations.clear();
|
|
||||||
};
|
|
||||||
auto advance_to_next_payout_time = [&]() {
|
auto advance_to_next_payout_time = [&]() {
|
||||||
// Advance to the next upcoming payout time
|
// Advance to the next upcoming payout time
|
||||||
BOOST_REQUIRE(dividend_data.options.next_payout_time);
|
BOOST_REQUIRE(dividend_data.options.next_payout_time);
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,6 @@ BOOST_AUTO_TEST_CASE( votes_on_gpos_activation )
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
// update default gpos
|
// update default gpos
|
||||||
auto now = db.head_block_time();
|
|
||||||
// 5184000 = 60x60x24x6 = 6 days
|
// 5184000 = 60x60x24x6 = 6 days
|
||||||
// 864000 = 60x60x24x1 = 1 days
|
// 864000 = 60x60x24x1 = 1 days
|
||||||
update_gpos_global(518400, 86400, HARDFORK_GPOS_TIME);
|
update_gpos_global(518400, 86400, HARDFORK_GPOS_TIME);
|
||||||
|
|
@ -671,10 +670,18 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
auto witness2 = witness_id_type(2)(db);
|
auto witness2 = witness_id_type(2)(db);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 0);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 0);
|
||||||
|
|
||||||
|
// vesting performance is 0 for both alice and bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 0);
|
||||||
|
|
||||||
// vote for witness1 and witness2 - sub-period 1
|
// vote for witness1 and witness2 - sub-period 1
|
||||||
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
||||||
|
// after voting, vesting performance is 1 for both alice and bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
// go to maint
|
// go to maint
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
|
||||||
|
|
@ -684,6 +691,10 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 1000);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 1000);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 1000);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 1000);
|
||||||
|
|
||||||
|
// vesting performance is 1 for both alice and bob during whole gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
advance_x_maint(6);
|
advance_x_maint(6);
|
||||||
|
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
|
|
@ -691,10 +702,29 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 100);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(4);
|
// vesting performance is 1 for both alice and bob during whole gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(3);
|
||||||
|
|
||||||
|
// vesting performance is 1 for both alice and bob during whole gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 5/6 for both alice and bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
//Bob votes for witness2 - sub-period 2
|
//Bob votes for witness2 - sub-period 2
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
||||||
|
// after voting, vesting performance is 5/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
// go to maint
|
// go to maint
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// vote decay as time pass
|
// vote decay as time pass
|
||||||
|
|
@ -704,9 +734,35 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 83);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 83);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
// after voting, vesting performance is 5/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 4/6 for alice and 5/6 for bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
//Bob votes for witness2 - sub-period 3
|
//Bob votes for witness2 - sub-period 3
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
||||||
|
// after voting, vesting performance is 4/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
// decay more
|
// decay more
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
|
|
@ -714,7 +770,27 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 66);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 66);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
// after voting, vesting performance is 4/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 3/6 for alice and 5/6 for bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 3.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
// Bob votes for witness2 - sub-period 4
|
// Bob votes for witness2 - sub-period 4
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
@ -725,7 +801,27 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 50);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 50);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
// after voting, vesting performance is 3/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 3.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 3.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 3.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 2/6 for alice and 5/6 for bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 2.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
// Bob votes for witness2 - sub-period 5
|
// Bob votes for witness2 - sub-period 5
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
@ -737,7 +833,27 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 33);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 33);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
// after voting, vesting performance is 2/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 2.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 2.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(4);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 2.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 1/6 for alice and 5/6 for bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
// Bob votes for witness2 - sub-period 6
|
// Bob votes for witness2 - sub-period 6
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
|
|
@ -748,14 +864,31 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 16);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 16);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
|
// after voting, vesting performance is 1/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
// we are still in gpos period 1
|
// we are still in gpos period 1
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
||||||
|
|
||||||
advance_x_maint(5);
|
advance_x_maint(8);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
// a new GPOS period is in but vote from user is before the start. Whoever votes in 6th sub-period, votes will carry
|
// a new GPOS period is in but vote from user is before the start. Whoever votes in 6th sub-period, votes will carry
|
||||||
now = db.head_block_time();
|
now = db.head_block_time();
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), HARDFORK_GPOS_TIME.sec_since_epoch() + db.get_global_properties().parameters.gpos_period());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), HARDFORK_GPOS_TIME.sec_since_epoch() + db.get_global_properties().parameters.gpos_period());
|
||||||
|
|
||||||
|
// new gpos period and his first subperiod started,
|
||||||
|
// vesting performance is decreased to 0 for alice, as she did not vote
|
||||||
|
// but stays 1 for bob, as he voted in last subperiod in previous gpos period
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1 );
|
||||||
|
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
// we are in the second GPOS period, at subperiod 1,
|
// we are in the second GPOS period, at subperiod 1,
|
||||||
|
|
@ -765,12 +898,14 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
//It's critical here, since bob votes in 6th sub-period of last vesting period, witness2 should retain his votes
|
//It's critical here, since bob votes in 6th sub-period of last vesting period, witness2 should retain his votes
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
|
|
||||||
// lets vote here from alice to generate votes for witness 1
|
// lets vote here from alice to generate votes for witness 1
|
||||||
//vote from bob to reatin VF 1
|
//vote from bob to reatin VF 1
|
||||||
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
vote_for(alice_id, witness1.vote_id, alice_private_key);
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_block();
|
|
||||||
|
// after voting, vesting performance is 1 for both alice and bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
// go to maint
|
// go to maint
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
|
@ -781,7 +916,17 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(witness1.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness1.total_votes, 100);
|
||||||
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
BOOST_CHECK_EQUAL(witness2.total_votes, 100);
|
||||||
|
|
||||||
advance_x_maint(10);
|
advance_x_maint(8);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 5/6 for both alice and bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
witness2 = witness_id_type(2)(db);
|
witness2 = witness_id_type(2)(db);
|
||||||
|
|
@ -792,7 +937,21 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
vote_for(bob_id, witness2.vote_id, bob_private_key);
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
advance_x_maint(10);
|
// after voting, vesting performance is 5/6 for alice and 1 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(9);
|
||||||
|
|
||||||
|
// vesting performance does not change during gpos subperiod
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 5.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 1);
|
||||||
|
|
||||||
|
advance_x_maint(1);
|
||||||
|
|
||||||
|
// new subperiod started, vesting performance is decreased to 4/6 for alice and 5/6 for bob, until they vote
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 4.0/6.0);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
witness2 = witness_id_type(2)(db);
|
witness2 = witness_id_type(2)(db);
|
||||||
|
|
@ -802,6 +961,11 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
|
|
||||||
// alice votes again, now for witness 2, her vote worth 100 now
|
// alice votes again, now for witness 2, her vote worth 100 now
|
||||||
vote_for(alice_id, witness2.vote_id, alice_private_key);
|
vote_for(alice_id, witness2.vote_id, alice_private_key);
|
||||||
|
|
||||||
|
// after voting, vesting performance is 1 for alice and 5.0/6.0 for bob
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(alice_id(db)), 1);
|
||||||
|
BOOST_CHECK_EQUAL(db.calculate_vesting_factor(bob_id(db)), 5.0/6.0);
|
||||||
|
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
|
|
@ -851,7 +1015,10 @@ BOOST_AUTO_TEST_CASE( worker_dividends_voting )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// advance to HF
|
// advance to HF
|
||||||
generate_blocks(HARDFORK_GPOS_TIME);
|
fc::time_point_sec GPOS_HARDFORK_TIME =
|
||||||
|
fc::time_point_sec(1581976800); // Use mainnet GPOS hardfork time
|
||||||
|
|
||||||
|
generate_blocks(GPOS_HARDFORK_TIME);
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
// update default gpos global parameters to 4 days
|
// update default gpos global parameters to 4 days
|
||||||
|
|
@ -905,7 +1072,7 @@ BOOST_AUTO_TEST_CASE( worker_dividends_voting )
|
||||||
vote_for(voter1_id, worker.vote_for, voter1_private_key);
|
vote_for(voter1_id, worker.vote_for, voter1_private_key);
|
||||||
|
|
||||||
// first maint pass, coefficient will be 1
|
// first maint pass, coefficient will be 1
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(GPOS_HARDFORK_TIME + fc::hours(12)); //forward 1/2 sub-period so that it consider only gpos votes
|
||||||
worker = worker_id_type()(db);
|
worker = worker_id_type()(db);
|
||||||
BOOST_CHECK_EQUAL(worker.total_votes_for, 100);
|
BOOST_CHECK_EQUAL(worker.total_votes_for, 100);
|
||||||
|
|
||||||
|
|
@ -925,8 +1092,8 @@ BOOST_AUTO_TEST_CASE( worker_dividends_voting )
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
||||||
|
|
||||||
// worker is getting paid
|
// worker is getting paid
|
||||||
BOOST_CHECK_EQUAL(worker_id_type()(db).worker.get<vesting_balance_worker_type>().balance(db).balance.amount.value, 10);
|
BOOST_CHECK_EQUAL(worker_id_type()(db).worker.get<vesting_balance_worker_type>().balance(db).balance.amount.value, 5);
|
||||||
BOOST_CHECK_EQUAL(worker.worker.get<vesting_balance_worker_type>().balance(db).balance.amount.value, 10);
|
BOOST_CHECK_EQUAL(worker.worker.get<vesting_balance_worker_type>().balance(db).balance.amount.value, 5);
|
||||||
|
|
||||||
// second maint pass, coefficient will be 0.75
|
// second maint pass, coefficient will be 0.75
|
||||||
worker = worker_id_type()(db);
|
worker = worker_id_type()(db);
|
||||||
|
|
@ -966,7 +1133,10 @@ BOOST_AUTO_TEST_CASE( account_multiple_vesting )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// advance to HF
|
// advance to HF
|
||||||
generate_blocks(HARDFORK_GPOS_TIME);
|
fc::time_point_sec GPOS_HARDFORK_TIME =
|
||||||
|
fc::time_point_sec(1581976800); // Use mainnet GPOS hardfork time
|
||||||
|
|
||||||
|
generate_blocks(GPOS_HARDFORK_TIME);
|
||||||
generate_block();
|
generate_block();
|
||||||
set_expiration(db, trx);
|
set_expiration(db, trx);
|
||||||
|
|
||||||
|
|
@ -1009,7 +1179,7 @@ BOOST_AUTO_TEST_CASE( account_multiple_vesting )
|
||||||
vote_for(sam_id, witness1.vote_id, sam_private_key);
|
vote_for(sam_id, witness1.vote_id, sam_private_key);
|
||||||
vote_for(patty_id, witness1.vote_id, patty_private_key);
|
vote_for(patty_id, witness1.vote_id, patty_private_key);
|
||||||
|
|
||||||
generate_blocks(db.get_dynamic_global_properties().next_maintenance_time);
|
generate_blocks(GPOS_HARDFORK_TIME + fc::hours(12)); //forward 1/2 sub-period so that it consider only gpos votes
|
||||||
|
|
||||||
// amount in vested balanced will sum up as voting power
|
// amount in vested balanced will sum up as voting power
|
||||||
witness1 = witness_id_type(1)(db);
|
witness1 = witness_id_type(1)(db);
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,8 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
||||||
// account_id_type() creates alice(not tracked account)
|
// account_id_type() creates alice(not tracked account)
|
||||||
const account_object& alice = create_account("alice");
|
const account_object& alice = create_account("alice");
|
||||||
auto alice_id = alice.id;
|
auto alice_id = alice.id;
|
||||||
|
(void)alice;
|
||||||
|
(void)alice_id;
|
||||||
|
|
||||||
//account_id_type() creates some ops
|
//account_id_type() creates some ops
|
||||||
create_bitasset("CNY", account_id_type());
|
create_bitasset("CNY", account_id_type());
|
||||||
|
|
@ -423,6 +425,8 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
||||||
// account_id_type() creates dan(account tracked)
|
// account_id_type() creates dan(account tracked)
|
||||||
const account_object& dan = create_account("dan");
|
const account_object& dan = create_account("dan");
|
||||||
auto dan_id = dan.id;
|
auto dan_id = dan.id;
|
||||||
|
(void)dan;
|
||||||
|
(void)dan_id;
|
||||||
|
|
||||||
// dan makes 1 op
|
// dan makes 1 op
|
||||||
create_bitasset("EUR", dan_id);
|
create_bitasset("EUR", dan_id);
|
||||||
|
|
@ -492,6 +496,8 @@ BOOST_AUTO_TEST_CASE(track_account2) {
|
||||||
// account_id_type() creates alice(tracked account)
|
// account_id_type() creates alice(tracked account)
|
||||||
const account_object& alice = create_account("alice");
|
const account_object& alice = create_account("alice");
|
||||||
auto alice_id = alice.id;
|
auto alice_id = alice.id;
|
||||||
|
(void)alice;
|
||||||
|
(void)alice_id;
|
||||||
|
|
||||||
//account_id_type() creates some ops
|
//account_id_type() creates some ops
|
||||||
create_bitasset("CNY", account_id_type());
|
create_bitasset("CNY", account_id_type());
|
||||||
|
|
@ -503,6 +509,8 @@ BOOST_AUTO_TEST_CASE(track_account2) {
|
||||||
// account_id_type() creates dan(account not tracked)
|
// account_id_type() creates dan(account not tracked)
|
||||||
const account_object& dan = create_account("dan");
|
const account_object& dan = create_account("dan");
|
||||||
auto dan_id = dan.id;
|
auto dan_id = dan.id;
|
||||||
|
(void)dan;
|
||||||
|
(void)dan_id;
|
||||||
|
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE( lottery_idx_test )
|
||||||
while( test_itr != test_asset_idx.end() ) {
|
while( test_itr != test_asset_idx.end() ) {
|
||||||
if( !met_not_active && (!test_itr->is_lottery() || !test_itr->lottery_options->is_active) )
|
if( !met_not_active && (!test_itr->is_lottery() || !test_itr->lottery_options->is_active) )
|
||||||
met_not_active = true;
|
met_not_active = true;
|
||||||
FC_ASSERT( !met_not_active || met_not_active && (!test_itr->is_lottery() || !test_itr->lottery_options->is_active), "MET ACTIVE LOTTERY AFTER NOT ACTIVE" );
|
FC_ASSERT( (!met_not_active) || (met_not_active && (!test_itr->is_lottery() || !test_itr->lottery_options->is_active)), "MET ACTIVE LOTTERY AFTER NOT ACTIVE" );
|
||||||
++test_itr;
|
++test_itr;
|
||||||
}
|
}
|
||||||
} catch (fc::exception& e) {
|
} catch (fc::exception& e) {
|
||||||
|
|
@ -128,7 +128,8 @@ BOOST_AUTO_TEST_CASE( tickets_purchase_test )
|
||||||
trx.operations.clear();
|
trx.operations.clear();
|
||||||
|
|
||||||
BOOST_CHECK( tpo.amount == db.get_balance( test_asset.get_id() ) );
|
BOOST_CHECK( tpo.amount == db.get_balance( test_asset.get_id() ) );
|
||||||
BOOST_CHECK( tpo.tickets_to_buy == get_balance( account_id_type(), test_asset.id ) );
|
int64_t tickets_to_buy_int64 = tpo.tickets_to_buy;
|
||||||
|
BOOST_CHECK( tickets_to_buy_int64 == get_balance( account_id_type(), test_asset.id ) );
|
||||||
|
|
||||||
} catch (fc::exception& e) {
|
} catch (fc::exception& e) {
|
||||||
edump((e.to_detail_string()));
|
edump((e.to_detail_string()));
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE( check_tansaction_for_duplicated_operations, database_fixture )
|
BOOST_FIXTURE_TEST_SUITE( check_transaction_for_duplicated_operations, database_fixture )
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( test_exception_throwing_for_the_same_operation_proposed_twice )
|
BOOST_AUTO_TEST_CASE( test_exception_throwing_for_the_same_operation_proposed_twice )
|
||||||
{
|
{
|
||||||
|
|
@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE( test_exception_throwing_for_the_same_operation_proposed_tw
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE( check_passes_without_duplication )
|
||||||
ACTORS((alice))
|
ACTORS((alice))
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
BOOST_CHECK_NO_THROW(db.check_transaction_for_duplicated_operations(trx));
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_the_same_operation_with_different_assets
|
||||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501))});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501))});
|
||||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
BOOST_CHECK_NO_THROW(db.check_transaction_for_duplicated_operations(trx));
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplication_in_transaction_with_several_op
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
||||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplicated_operation_in_existed_proposal_w
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(501)),
|
||||||
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_duplicated_operation_in_existed_proposal_w
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))}); //duplicated one
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_different_operations_types )
|
||||||
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
create_proposal(*this, {make_transfer_operation(account_id_type(), alice_id, asset(500))});
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
BOOST_CHECK_NO_THROW(db.check_transaction_for_duplicated_operations(trx));
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_same_member_create_operations )
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_different_member_create_operations )
|
||||||
create_proposal(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
create_proposal(*this, {make_committee_member_create_operation(asset(1000), account_id_type(), "test url")});
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1001), account_id_type(), "test url")});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_committee_member_create_operation(asset(1001), account_id_type(), "test url")});
|
||||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
BOOST_CHECK_NO_THROW(db.check_transaction_for_duplicated_operations(trx));
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -272,7 +272,7 @@ BOOST_AUTO_TEST_CASE( check_failes_for_several_operations_of_mixed_type )
|
||||||
make_committee_member_create_operation(asset(1002), account_id_type(), "test url")});
|
make_committee_member_create_operation(asset(1002), account_id_type(), "test url")});
|
||||||
|
|
||||||
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
//Modifying from BOOST_CHECK to BOOST_WARN just to make sure users might confuse about this error. If any changes in network_boradcast, would recommend to revert the changes
|
||||||
BOOST_WARN_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_WARN_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -298,7 +298,7 @@ BOOST_AUTO_TEST_CASE( check_failes_for_duplicates_in_pending_transactions_list )
|
||||||
push_proposal(*this, moneyman, {duplicate});
|
push_proposal(*this, moneyman, {duplicate});
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate});
|
||||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_CHECK_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -323,7 +323,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_no_duplicates_in_pending_transactions_lis
|
||||||
push_proposal(*this, moneyman, {make_transfer_operation(alice.id, moneyman.get_id(), asset(100))});
|
push_proposal(*this, moneyman, {make_transfer_operation(alice.id, moneyman.get_id(), asset(100))});
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(alice.id, moneyman.get_id(), asset(101))});
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {make_transfer_operation(alice.id, moneyman.get_id(), asset(101))});
|
||||||
BOOST_CHECK_NO_THROW(db.check_tansaction_for_duplicated_operations(trx));
|
BOOST_CHECK_NO_THROW(db.check_transaction_for_duplicated_operations(trx));
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE( check_fails_for_several_transactions_with_duplicates_in_pe
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate,
|
auto trx = make_signed_transaction_with_proposed_operation(*this, {duplicate,
|
||||||
make_transfer_operation(alice.id, moneyman.get_id(), asset(102))});
|
make_transfer_operation(alice.id, moneyman.get_id(), asset(102))});
|
||||||
BOOST_CHECK_THROW(db.check_tansaction_for_duplicated_operations(trx), fc::exception);
|
BOOST_CHECK_THROW(db.check_transaction_for_duplicated_operations(trx), fc::exception);
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
@ -412,7 +412,7 @@ BOOST_AUTO_TEST_CASE( check_passes_for_duplicated_betting_market_or_group )
|
||||||
create_proposal(*this, { pcop1, pcop2 });
|
create_proposal(*this, { pcop1, pcop2 });
|
||||||
|
|
||||||
auto trx = make_signed_transaction_with_proposed_operation(*this, { pcop1, pcop2 });
|
auto trx = make_signed_transaction_with_proposed_operation(*this, { pcop1, pcop2 });
|
||||||
BOOST_CHECK_NO_THROW( db.check_tansaction_for_duplicated_operations(trx) );
|
BOOST_CHECK_NO_THROW( db.check_transaction_for_duplicated_operations(trx) );
|
||||||
}
|
}
|
||||||
catch( const fc::exception& e )
|
catch( const fc::exception& e )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1561,7 +1561,6 @@ BOOST_AUTO_TEST_CASE( vesting_balance_create_test )
|
||||||
op.amount = test_asset.amount( 100 );
|
op.amount = test_asset.amount( 100 );
|
||||||
//op.vesting_seconds = 60*60*24;
|
//op.vesting_seconds = 60*60*24;
|
||||||
op.policy = cdd_vesting_policy_initializer{ 60*60*24 };
|
op.policy = cdd_vesting_policy_initializer{ 60*60*24 };
|
||||||
op.balance_type == vesting_balance_type::normal;
|
|
||||||
|
|
||||||
// Fee must be non-negative
|
// Fee must be non-negative
|
||||||
REQUIRE_OP_VALIDATION_SUCCESS( op, fee, core.amount(1) );
|
REQUIRE_OP_VALIDATION_SUCCESS( op, fee, core.amount(1) );
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy)
|
||||||
PUSH_TX( db, trx, ~0 );
|
PUSH_TX( db, trx, ~0 );
|
||||||
}
|
}
|
||||||
// last_vote_time is not updated
|
// last_vote_time is not updated
|
||||||
auto round2 = db.head_block_time().sec_since_epoch();
|
db.head_block_time().sec_since_epoch();
|
||||||
alice_stats_obj = alice_id(db).statistics(db);
|
alice_stats_obj = alice_id(db).statistics(db);
|
||||||
BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1);
|
BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1731,7 +1731,8 @@ BOOST_FIXTURE_TEST_CASE( ties, database_fixture )
|
||||||
share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
|
share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
|
||||||
optional<account_id_type> dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id);
|
optional<account_id_type> dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id);
|
||||||
if (dividend_account.valid())
|
if (dividend_account.valid())
|
||||||
players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount;
|
players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount;
|
||||||
|
players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount;
|
||||||
|
|
||||||
tournaments.erase(tournament_id);
|
tournaments.erase(tournament_id);
|
||||||
--tournaments_to_complete;
|
--tournaments_to_complete;
|
||||||
|
|
@ -1943,7 +1944,8 @@ BOOST_FIXTURE_TEST_CASE( assets, database_fixture )
|
||||||
share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
|
share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64();
|
||||||
optional<account_id_type> dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id);
|
optional<account_id_type> dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id);
|
||||||
if (dividend_account.valid())
|
if (dividend_account.valid())
|
||||||
players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount;
|
players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount;
|
||||||
|
players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount;
|
||||||
|
|
||||||
tournaments.erase(tournament_id);
|
tournaments.erase(tournament_id);
|
||||||
--tournaments_to_complete;
|
--tournaments_to_complete;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue