Merge branch 'develop' into feature/nft_lottery
This commit is contained in:
commit
ed269951a3
45 changed files with 139 additions and 704 deletions
|
|
@ -128,7 +128,7 @@ else( WIN32 ) # Apple AND Linux
|
|||
endif( APPLE )
|
||||
|
||||
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp -Wno-parentheses -Wno-terminate -Wno-invalid-offsetof" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp -Wno-parentheses -Wno-terminate -Wno-invalid-offsetof -Wno-sign-compare" )
|
||||
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 )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
add_subdirectory( fc )
|
||||
add_subdirectory( db )
|
||||
#add_subdirectory( deterministic_openssl_rand )
|
||||
add_subdirectory( app )
|
||||
add_subdirectory( chain )
|
||||
add_subdirectory( db )
|
||||
add_subdirectory( egenesis )
|
||||
add_subdirectory( fc )
|
||||
add_subdirectory( net )
|
||||
#add_subdirectory( p2p )
|
||||
add_subdirectory( plugins )
|
||||
add_subdirectory( time )
|
||||
add_subdirectory( utilities )
|
||||
add_subdirectory( app )
|
||||
add_subdirectory( plugins )
|
||||
add_subdirectory( wallet )
|
||||
|
|
|
|||
|
|
@ -4,16 +4,19 @@ file(GLOB EGENESIS_HEADERS "../egenesis/include/graphene/app/*.hpp")
|
|||
add_library( graphene_app
|
||||
api.cpp
|
||||
application.cpp
|
||||
config_util.cpp
|
||||
database_api.cpp
|
||||
plugin.cpp
|
||||
config_util.cpp
|
||||
${HEADERS}
|
||||
${EGENESIS_HEADERS}
|
||||
)
|
||||
|
||||
# need to link graphene_debug_witness because plugins aren't sufficiently isolated #246
|
||||
#target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness )
|
||||
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness graphene_bookie graphene_elasticsearch peerplays_sidechain )
|
||||
target_link_libraries( graphene_app
|
||||
PUBLIC graphene_net graphene_utilities
|
||||
graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch graphene_es_objects graphene_generate_genesis graphene_market_history )
|
||||
|
||||
target_include_directories( graphene_app
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
|
||||
|
|
@ -30,3 +33,26 @@ INSTALL( TARGETS
|
|||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/app" )
|
||||
|
||||
|
||||
|
||||
add_library( graphene_plugin
|
||||
plugin.cpp
|
||||
|
||||
include/graphene/app/plugin.hpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_plugin
|
||||
PUBLIC graphene_net graphene_utilities )
|
||||
|
||||
target_include_directories( graphene_plugin
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
INSTALL( TARGETS
|
||||
graphene_app
|
||||
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ namespace graphene { namespace app {
|
|||
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
|
||||
{
|
||||
_app.chain_database()->check_tansaction_for_duplicated_operations(trx);
|
||||
|
||||
|
||||
fc::promise<fc::variant>::ptr prom( new fc::promise<fc::variant>() );
|
||||
broadcast_transaction_with_callback( [=]( const fc::variant& v ){
|
||||
prom->set_value(v);
|
||||
|
|
@ -639,7 +639,7 @@ namespace graphene { namespace app {
|
|||
try {
|
||||
account = database_api.get_account_id_from_string(account_id_or_name);
|
||||
} catch (...) { return result; }
|
||||
|
||||
|
||||
const auto& stats = account(db).statistics(db);
|
||||
if( stats.most_recent_op == account_transaction_history_id_type() ) return result;
|
||||
const account_transaction_history_object* node = &stats.most_recent_op(db);
|
||||
|
|
@ -676,7 +676,7 @@ namespace graphene { namespace app {
|
|||
FC_ASSERT( limit <= api_limit_get_relative_account_history,
|
||||
"Number of querying accounts can not be greater than ${configured_limit}",
|
||||
("configured_limit", api_limit_get_relative_account_history) );
|
||||
|
||||
|
||||
vector<operation_history_object> result;
|
||||
account_id_type account;
|
||||
try {
|
||||
|
|
@ -806,7 +806,7 @@ namespace graphene { namespace app {
|
|||
}
|
||||
|
||||
// asset_api
|
||||
asset_api::asset_api(graphene::app::application& app) :
|
||||
asset_api::asset_api(graphene::app::application& app) :
|
||||
_app(app),
|
||||
_db( *app.chain_database()),
|
||||
database_api( std::ref(*app.chain_database())) { }
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
|||
uint32_t api_limit_lookup_committee_member_accounts = 1000;
|
||||
uint32_t api_limit_get_trade_history = 100;
|
||||
uint32_t api_limit_get_trade_history_by_sequence = 100;
|
||||
|
||||
|
||||
// Account Role
|
||||
vector<account_role_object> get_account_roles_by_owner(account_id_type owner) const;
|
||||
// rng
|
||||
|
|
@ -930,7 +930,7 @@ vector<asset> database_api::get_account_balances(const std::string& account_name
|
|||
return my->get_account_balances( account_name_or_id, assets );
|
||||
}
|
||||
|
||||
vector<asset> database_api_impl::get_account_balances( const std::string& account_name_or_id,
|
||||
vector<asset> database_api_impl::get_account_balances( const std::string& account_name_or_id,
|
||||
const flat_set<asset_id_type>& assets)const
|
||||
{
|
||||
const account_object* account = get_account_from_string(account_name_or_id);
|
||||
|
|
@ -2604,9 +2604,9 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
|
|||
&& balance.balance.asset_id == asset_id_type())
|
||||
account_vbos.emplace_back(balance);
|
||||
});
|
||||
|
||||
|
||||
share_type allowed_withdraw_amount = 0, account_vested_balance = 0;
|
||||
|
||||
|
||||
for (const vesting_balance_object& vesting_balance_obj : account_vbos)
|
||||
{
|
||||
account_vested_balance += vesting_balance_obj.balance.amount;
|
||||
|
|
|
|||
|
|
@ -8,149 +8,29 @@ add_dependencies( build_hardfork_hpp cat-parts )
|
|||
file(GLOB HEADERS "include/graphene/chain/*.hpp")
|
||||
file(GLOB PROTOCOL_HEADERS "include/graphene/chain/protocol/*.hpp")
|
||||
|
||||
if( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
set( GRAPHENE_DB_FILES
|
||||
db_balance.cpp
|
||||
db_bet.cpp
|
||||
db_block.cpp
|
||||
db_debug.cpp
|
||||
db_getter.cpp
|
||||
db_init.cpp
|
||||
db_maint.cpp
|
||||
db_management.cpp
|
||||
db_market.cpp
|
||||
db_update.cpp
|
||||
db_witness_schedule.cpp
|
||||
)
|
||||
file(GLOB CPP_FILES "*.cpp")
|
||||
file(GLOB PROTOCOL_CPP_FILES "protocol/*.cpp")
|
||||
|
||||
#if( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$")
|
||||
#message ("--- ${CPP_FILES}")
|
||||
message( STATUS "Graphene database unity build disabled" )
|
||||
else( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
set( GRAPHENE_DB_FILES
|
||||
database.cpp )
|
||||
message( STATUS "Graphene database unity build enabled" )
|
||||
endif( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
#else( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
# list(FILTER CPP_FILES EXCLUDE REGEX ".*db_.*[.]cpp$")
|
||||
# #message ("--- ${CPP_FILES}")
|
||||
# message( STATUS "Graphene database unity build enabled" )
|
||||
#endif( GRAPHENE_DISABLE_UNITY_BUILD )
|
||||
|
||||
## SORT .cpp by most likely to change / break compile
|
||||
add_library( graphene_chain
|
||||
|
||||
# As database takes the longest to compile, start it first
|
||||
${GRAPHENE_DB_FILES}
|
||||
fork_database.cpp
|
||||
|
||||
protocol/types.cpp
|
||||
protocol/address.cpp
|
||||
protocol/authority.cpp
|
||||
protocol/asset.cpp
|
||||
protocol/assert.cpp
|
||||
protocol/account.cpp
|
||||
protocol/transfer.cpp
|
||||
protocol/chain_parameters.cpp
|
||||
protocol/committee_member.cpp
|
||||
protocol/witness.cpp
|
||||
protocol/market.cpp
|
||||
protocol/proposal.cpp
|
||||
protocol/withdraw_permission.cpp
|
||||
protocol/asset_ops.cpp
|
||||
protocol/lottery_ops.cpp
|
||||
protocol/memo.cpp
|
||||
protocol/worker.cpp
|
||||
protocol/custom.cpp
|
||||
protocol/operations.cpp
|
||||
protocol/transaction.cpp
|
||||
protocol/block.cpp
|
||||
protocol/fee_schedule.cpp
|
||||
protocol/confidential.cpp
|
||||
protocol/vote.cpp
|
||||
protocol/tournament.cpp
|
||||
protocol/small_ops.cpp
|
||||
protocol/custom_permission.cpp
|
||||
protocol/custom_account_authority.cpp
|
||||
protocol/offer.cpp
|
||||
|
||||
genesis_state.cpp
|
||||
get_config.cpp
|
||||
|
||||
pts_address.cpp
|
||||
|
||||
evaluator.cpp
|
||||
balance_evaluator.cpp
|
||||
account_evaluator.cpp
|
||||
assert_evaluator.cpp
|
||||
witness_evaluator.cpp
|
||||
committee_member_evaluator.cpp
|
||||
asset_evaluator.cpp
|
||||
lottery_evaluator.cpp
|
||||
transfer_evaluator.cpp
|
||||
proposal_evaluator.cpp
|
||||
market_evaluator.cpp
|
||||
vesting_balance_evaluator.cpp
|
||||
tournament_evaluator.cpp
|
||||
tournament_object.cpp
|
||||
match_object.cpp
|
||||
game_object.cpp
|
||||
withdraw_permission_evaluator.cpp
|
||||
worker_evaluator.cpp
|
||||
confidential_evaluator.cpp
|
||||
special_authority.cpp
|
||||
buyback.cpp
|
||||
|
||||
account_object.cpp
|
||||
asset_object.cpp
|
||||
fba_object.cpp
|
||||
proposal_object.cpp
|
||||
vesting_balance_object.cpp
|
||||
small_objects.cpp
|
||||
|
||||
block_database.cpp
|
||||
|
||||
is_authorized_asset.cpp
|
||||
|
||||
protocol/sport.cpp
|
||||
sport_evaluator.cpp
|
||||
protocol/event_group.cpp
|
||||
event_group_evaluator.cpp
|
||||
event_group_object.cpp
|
||||
protocol/event.cpp
|
||||
event_evaluator.cpp
|
||||
event_object.cpp
|
||||
protocol/betting_market.cpp
|
||||
betting_market_evaluator.cpp
|
||||
betting_market_object.cpp
|
||||
betting_market_group_object.cpp
|
||||
custom_permission_evaluator.cpp
|
||||
custom_account_authority_evaluator.cpp
|
||||
|
||||
affiliate_payout.cpp
|
||||
|
||||
offer_object.cpp
|
||||
offer_evaluator.cpp
|
||||
nft_evaluator.cpp
|
||||
protocol/nft.cpp
|
||||
protocol/account_role.cpp
|
||||
account_role_evaluator.cpp
|
||||
|
||||
son_evaluator.cpp
|
||||
son_object.cpp
|
||||
|
||||
son_wallet_evaluator.cpp
|
||||
son_wallet_deposit_evaluator.cpp
|
||||
son_wallet_withdraw_evaluator.cpp
|
||||
|
||||
sidechain_address_evaluator.cpp
|
||||
sidechain_transaction_evaluator.cpp
|
||||
|
||||
protocol/nft_lottery.cpp
|
||||
nft_lottery_evaluator.cpp
|
||||
nft_lottery_object.cpp
|
||||
|
||||
random_number_evaluator.cpp
|
||||
|
||||
${CPP_FILES}
|
||||
${PROTOCOL_CPP_FILES}
|
||||
${HEADERS}
|
||||
${PROTOCOL_HEADERS}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp"
|
||||
)
|
||||
|
||||
add_dependencies( graphene_chain build_hardfork_hpp )
|
||||
target_link_libraries( graphene_chain fc graphene_db )
|
||||
target_link_libraries( graphene_chain graphene_db )
|
||||
target_include_directories( graphene_chain
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@
|
|||
#include "db_maint.cpp"
|
||||
#include "db_management.cpp"
|
||||
#include "db_market.cpp"
|
||||
#include "db_notify.cpp"
|
||||
#include "db_update.cpp"
|
||||
#include "db_witness_schedule.cpp"
|
||||
#include "db_notify.cpp"
|
||||
|
|
@ -32,22 +32,24 @@
|
|||
#include <graphene/chain/is_authorized_asset.hpp>
|
||||
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/account_role_object.hpp>
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/budget_record_object.hpp>
|
||||
#include <graphene/chain/buyback_object.hpp>
|
||||
#include <graphene/chain/chain_property_object.hpp>
|
||||
#include <graphene/chain/committee_member_object.hpp>
|
||||
#include <graphene/chain/custom_account_authority_object.hpp>
|
||||
#include <graphene/chain/fba_object.hpp>
|
||||
#include <graphene/chain/global_property_object.hpp>
|
||||
#include <graphene/chain/market_object.hpp>
|
||||
#include <graphene/chain/special_authority_object.hpp>
|
||||
#include <graphene/chain/son_object.hpp>
|
||||
#include <graphene/chain/son_wallet_object.hpp>
|
||||
#include <graphene/chain/vesting_balance_object.hpp>
|
||||
#include <graphene/chain/vote_count.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/witness_schedule_object.hpp>
|
||||
#include <graphene/chain/worker_object.hpp>
|
||||
#include <graphene/chain/custom_account_authority_object.hpp>
|
||||
|
||||
#define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <graphene/chain/witness_schedule_object.hpp>
|
||||
#include <graphene/chain/special_authority_object.hpp>
|
||||
#include <graphene/chain/operation_history_object.hpp>
|
||||
#include <graphene/chain/nft_object.hpp>
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
|
||||
#include <fc/io/fstream.hpp>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <fc/container/flat.hpp>
|
||||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/protocol/authority.hpp>
|
||||
#include <graphene/chain/protocol/operations.hpp>
|
||||
#include <graphene/chain/protocol/transaction.hpp>
|
||||
|
|
@ -41,6 +42,10 @@
|
|||
#include <graphene/chain/transaction_object.hpp>
|
||||
#include <graphene/chain/impacted.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/account_role_object.hpp>
|
||||
#include <graphene/chain/son_object.hpp>
|
||||
#include <graphene/chain/sidechain_address_object.hpp>
|
||||
|
||||
|
||||
using namespace fc;
|
||||
|
|
|
|||
|
|
@ -26,16 +26,18 @@
|
|||
#include <graphene/chain/db_with.hpp>
|
||||
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/betting_market_object.hpp>
|
||||
#include <graphene/chain/game_object.hpp>
|
||||
#include <graphene/chain/global_property_object.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
#include <graphene/chain/market_object.hpp>
|
||||
#include <graphene/chain/offer_object.hpp>
|
||||
#include <graphene/chain/proposal_object.hpp>
|
||||
#include <graphene/chain/son_proposal_object.hpp>
|
||||
#include <graphene/chain/tournament_object.hpp>
|
||||
#include <graphene/chain/transaction_object.hpp>
|
||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/tournament_object.hpp>
|
||||
#include <graphene/chain/game_object.hpp>
|
||||
#include <graphene/chain/betting_market_object.hpp>
|
||||
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
// SON HARDFORK Wednesday, January 1, 2020 12:00:00 AM - 1577836800
|
||||
// SON HARDFORK Monday, March 30, 2020 3:00:00 PM - 1585573200
|
||||
// SON HARDFORK Monday, September 21, 2020 1:43:11 PM - 1600695791
|
||||
// SON HARDFORK Wednesday, October 28, 2020 0:00:00 GMT
|
||||
#ifndef HARDFORK_SON_TIME
|
||||
#include <ctime>
|
||||
#define HARDFORK_SON_TIME (fc::time_point_sec( 1585573200 ))
|
||||
#define HARDFORK_SON_TIME (fc::time_point_sec( 1603843200 ))
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include <fc/io/raw.hpp>
|
||||
#include <graphene/chain/index.hpp>
|
||||
#include <graphene/chain/database.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
void base_primary_index::save_undo( const object& obj )
|
||||
{ _db.save_undo( obj ); }
|
||||
|
||||
void base_primary_index::on_add( const object& obj )
|
||||
{
|
||||
_db.save_undo_add( obj );
|
||||
for( auto ob : _observers ) ob->on_add( obj );
|
||||
}
|
||||
|
||||
void base_primary_index::on_remove( const object& obj )
|
||||
{ _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); }
|
||||
|
||||
void base_primary_index::on_modify( const object& obj )
|
||||
{for( auto ob : _observers ) ob->on_modify( obj ); }
|
||||
} } // graphene::chain
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Peerplays Blockchain Standards Association, and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include <graphene/chain/protocol/competitor.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
void competitor_create_operation::validate() const
|
||||
{
|
||||
FC_ASSERT( fee.amount >= 0 );
|
||||
}
|
||||
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include <graphene/chain/transaction_object.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
const object* transaction_index::create(const std::function<void (object*)>& constructor, object_id_type)
|
||||
{
|
||||
transaction_object obj;
|
||||
|
||||
obj.id = get_next_available_id();
|
||||
constructor(&obj);
|
||||
|
||||
auto result = _index.insert(std::move(obj));
|
||||
FC_ASSERT(result.second, "Could not create transaction_object! Most likely a uniqueness constraint is violated.");
|
||||
return &*result.first;
|
||||
}
|
||||
|
||||
void transaction_index::modify(const object* obj,
|
||||
const std::function<void (object*)>& m)
|
||||
{
|
||||
assert(obj != nullptr);
|
||||
FC_ASSERT(obj->id < _index.size());
|
||||
|
||||
const transaction_object* t = dynamic_cast<const transaction_object*>(obj);
|
||||
assert(t != nullptr);
|
||||
|
||||
auto itr = _index.find(obj->id.instance());
|
||||
assert(itr != _index.end());
|
||||
_index.modify(itr, [&m](transaction_object& o) { m(&o); });
|
||||
}
|
||||
|
||||
void transaction_index::add(unique_ptr<object> o)
|
||||
{
|
||||
assert(o);
|
||||
object_id_type id = o->id;
|
||||
assert(id.space() == transaction_object::space_id);
|
||||
assert(id.type() == transaction_object::type_id);
|
||||
assert(id.instance() == size());
|
||||
|
||||
auto trx = dynamic_cast<transaction_object*>(o.get());
|
||||
assert(trx != nullptr);
|
||||
o.release();
|
||||
|
||||
auto result = _index.insert(std::move(*trx));
|
||||
FC_ASSERT(result.second, "Could not insert transaction_object! Most likely a uniqueness constraint is violated.");
|
||||
}
|
||||
|
||||
void transaction_index::remove(object_id_type id)
|
||||
{
|
||||
auto& index = _index.get<instance>();
|
||||
auto itr = index.find(id.instance());
|
||||
if( itr == index.end() )
|
||||
return;
|
||||
|
||||
assert(id.space() == transaction_object::space_id);
|
||||
assert(id.type() == transaction_object::type_id);
|
||||
|
||||
index.erase(itr);
|
||||
}
|
||||
|
||||
const object*transaction_index::get(object_id_type id) const
|
||||
{
|
||||
if( id.type() != transaction_object::type_id ||
|
||||
id.space() != transaction_object::space_id )
|
||||
return nullptr;
|
||||
|
||||
auto itr = _index.find(id.instance());
|
||||
if( itr == _index.end() )
|
||||
return nullptr;
|
||||
return &*itr;
|
||||
}
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
@ -4,7 +4,7 @@ add_library( graphene_egenesis_none
|
|||
include/graphene/egenesis/egenesis.hpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_egenesis_none graphene_chain fc )
|
||||
target_link_libraries( graphene_egenesis_none graphene_chain )
|
||||
target_include_directories( graphene_egenesis_none
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ add_executable( embed_genesis
|
|||
embed_genesis.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( embed_genesis graphene_chain graphene_app graphene_egenesis_none fc )
|
||||
target_link_libraries( embed_genesis PRIVATE graphene_app graphene_egenesis_none )
|
||||
|
||||
set( embed_genesis_args
|
||||
-t "${CMAKE_CURRENT_SOURCE_DIR}/egenesis_brief.cpp.tmpl---${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp"
|
||||
|
|
@ -42,8 +42,8 @@ add_custom_command(
|
|||
add_library( graphene_egenesis_brief "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" include/graphene/egenesis/egenesis.hpp )
|
||||
add_library( graphene_egenesis_full "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" include/graphene/egenesis/egenesis.hpp )
|
||||
|
||||
target_link_libraries( graphene_egenesis_brief graphene_chain fc )
|
||||
target_link_libraries( graphene_egenesis_full graphene_chain fc )
|
||||
target_link_libraries( graphene_egenesis_brief graphene_chain )
|
||||
target_link_libraries( graphene_egenesis_full graphene_chain )
|
||||
|
||||
target_include_directories( graphene_egenesis_brief
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
|
|
|||
|
|
@ -10,12 +10,8 @@ set(SOURCES node.cpp
|
|||
|
||||
add_library( graphene_net ${SOURCES} ${HEADERS} )
|
||||
|
||||
target_link_libraries( graphene_net
|
||||
PUBLIC fc graphene_db )
|
||||
target_include_directories( graphene_net
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include"
|
||||
)
|
||||
target_link_libraries( graphene_net graphene_chain )
|
||||
target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
if(MSVC)
|
||||
set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
add_subdirectory( witness )
|
||||
add_subdirectory( account_history )
|
||||
add_subdirectory( accounts_list )
|
||||
add_subdirectory( affiliate_stats )
|
||||
add_subdirectory( elasticsearch )
|
||||
add_subdirectory( market_history )
|
||||
add_subdirectory( delayed_node )
|
||||
add_subdirectory( bookie )
|
||||
add_subdirectory( debug_witness )
|
||||
add_subdirectory( delayed_node )
|
||||
add_subdirectory( elasticsearch )
|
||||
add_subdirectory( es_objects )
|
||||
add_subdirectory( generate_genesis )
|
||||
add_subdirectory( generate_uia_sharedrop_genesis )
|
||||
add_subdirectory( debug_witness )
|
||||
add_subdirectory( snapshot )
|
||||
add_subdirectory( market_history )
|
||||
add_subdirectory( peerplays_sidechain )
|
||||
add_subdirectory( es_objects )
|
||||
add_subdirectory( snapshot )
|
||||
add_subdirectory( witness )
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_account_history
|
|||
account_history_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_account_history graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_account_history PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_account_history
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_accounts_list
|
|||
accounts_list_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_accounts_list graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_accounts_list PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_accounts_list
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ add_library( graphene_affiliate_stats
|
|||
affiliate_stats_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_affiliate_stats graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_affiliate_stats PRIVATE graphene_plugin graphene_account_history )
|
||||
target_include_directories( graphene_affiliate_stats
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ add_library( graphene_bookie
|
|||
bookie_api.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_bookie graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_bookie PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_bookie
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ add_library( graphene_debug_witness
|
|||
debug_witness.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_debug_witness graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_debug_witness PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_debug_witness
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_delayed_node
|
|||
delayed_node_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_delayed_node graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_delayed_node PRIVATE graphene_plugin graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch graphene_market_history )
|
||||
target_include_directories( graphene_delayed_node
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_elasticsearch
|
|||
elasticsearch_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_elasticsearch graphene_chain graphene_app curl )
|
||||
target_link_libraries( graphene_elasticsearch PRIVATE graphene_plugin curl )
|
||||
target_include_directories( graphene_elasticsearch
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_es_objects
|
|||
es_objects.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_es_objects graphene_chain graphene_app curl )
|
||||
target_link_libraries( graphene_es_objects PRIVATE graphene_plugin curl )
|
||||
target_include_directories( graphene_es_objects
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_generate_genesis
|
|||
generate_genesis.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_generate_genesis graphene_chain graphene_app graphene_time )
|
||||
target_link_libraries( graphene_generate_genesis PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_generate_genesis
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_generate_uia_sharedrop_genesis
|
|||
generate_uia_sharedrop_genesis.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_generate_uia_sharedrop_genesis graphene_chain graphene_app graphene_time )
|
||||
target_link_libraries( graphene_generate_uia_sharedrop_genesis PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_generate_uia_sharedrop_genesis
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -1,303 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Abit More, and contributors.
|
||||
*
|
||||
* The MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <graphene/grouped_orders/grouped_orders_plugin.hpp>
|
||||
|
||||
#include <graphene/chain/market_object.hpp>
|
||||
|
||||
namespace graphene { namespace grouped_orders {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class grouped_orders_plugin_impl
|
||||
{
|
||||
public:
|
||||
grouped_orders_plugin_impl(grouped_orders_plugin& _plugin)
|
||||
:_self( _plugin ) {}
|
||||
virtual ~grouped_orders_plugin_impl();
|
||||
|
||||
graphene::chain::database& database()
|
||||
{
|
||||
return _self.database();
|
||||
}
|
||||
|
||||
grouped_orders_plugin& _self;
|
||||
flat_set<uint16_t> _tracked_groups;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This secondary index is used to track changes on limit order objects.
|
||||
*/
|
||||
class limit_order_group_index : public secondary_index
|
||||
{
|
||||
public:
|
||||
limit_order_group_index( const flat_set<uint16_t>& groups ) : _tracked_groups( groups ) {};
|
||||
|
||||
virtual void object_inserted( const object& obj ) override;
|
||||
virtual void object_removed( const object& obj ) override;
|
||||
virtual void about_to_modify( const object& before ) override;
|
||||
virtual void object_modified( const object& after ) override;
|
||||
|
||||
const flat_set<uint16_t>& get_tracked_groups() const
|
||||
{ return _tracked_groups; }
|
||||
|
||||
const map< limit_order_group_key, limit_order_group_data >& get_order_groups() const
|
||||
{ return _og_data; }
|
||||
|
||||
private:
|
||||
void remove_order( const limit_order_object& obj, bool remove_empty = true );
|
||||
|
||||
/** tracked groups */
|
||||
flat_set<uint16_t> _tracked_groups;
|
||||
|
||||
/** maps the group key to group data */
|
||||
map< limit_order_group_key, limit_order_group_data > _og_data;
|
||||
};
|
||||
|
||||
void limit_order_group_index::object_inserted( const object& objct )
|
||||
{ try {
|
||||
const limit_order_object& o = static_cast<const limit_order_object&>( objct );
|
||||
|
||||
auto& idx = _og_data;
|
||||
|
||||
for( uint16_t group : get_tracked_groups() )
|
||||
{
|
||||
auto create_ogo = [&]() {
|
||||
idx[ limit_order_group_key( group, o.sell_price ) ] = limit_order_group_data( o.sell_price, o.for_sale );
|
||||
};
|
||||
// if idx is empty, insert this order
|
||||
// Note: not capped
|
||||
if( idx.empty() )
|
||||
{
|
||||
create_ogo();
|
||||
continue;
|
||||
}
|
||||
|
||||
// cap the price
|
||||
price capped_price = o.sell_price;
|
||||
price max = o.sell_price.max();
|
||||
price min = o.sell_price.min();
|
||||
bool capped_max = false;
|
||||
bool capped_min = false;
|
||||
if( o.sell_price > max )
|
||||
{
|
||||
capped_price = max;
|
||||
capped_max = true;
|
||||
}
|
||||
else if( o.sell_price < min )
|
||||
{
|
||||
capped_price = min;
|
||||
capped_min = true;
|
||||
}
|
||||
// if idx is not empty, find the group that is next to this order
|
||||
auto itr = idx.lower_bound( limit_order_group_key( group, capped_price ) );
|
||||
bool check_previous = false;
|
||||
if( itr == idx.end() || itr->first.group != group
|
||||
|| itr->first.min_price.base.asset_id != o.sell_price.base.asset_id
|
||||
|| itr->first.min_price.quote.asset_id != o.sell_price.quote.asset_id )
|
||||
// not same market or group type
|
||||
check_previous = true;
|
||||
else // same market and group type
|
||||
{
|
||||
bool update_max = false;
|
||||
if( capped_price > itr->second.max_price ) // implies itr->min_price <= itr->max_price < max
|
||||
{
|
||||
update_max = true;
|
||||
price max_price = itr->first.min_price * ratio_type( GRAPHENE_100_PERCENT + group, GRAPHENE_100_PERCENT );
|
||||
// max_price should have been capped here
|
||||
if( capped_price > max_price ) // new order is out of range
|
||||
check_previous = true;
|
||||
}
|
||||
if( !check_previous ) // new order is within the range
|
||||
{
|
||||
if( capped_min && o.sell_price < itr->first.min_price )
|
||||
{ // need to update itr->min_price here, if itr is below min, and new order is even lower
|
||||
// TODO improve performance
|
||||
limit_order_group_data data( itr->second.max_price, o.for_sale + itr->second.total_for_sale );
|
||||
idx.erase( itr );
|
||||
idx[ limit_order_group_key( group, o.sell_price ) ] = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( update_max || ( capped_max && o.sell_price > itr->second.max_price ) )
|
||||
itr->second.max_price = o.sell_price; // store real price here, not capped
|
||||
itr->second.total_for_sale += o.for_sale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( check_previous )
|
||||
{
|
||||
if( itr == idx.begin() ) // no previous
|
||||
create_ogo();
|
||||
else
|
||||
{
|
||||
--itr; // should be valid
|
||||
if( itr->first.group != group || itr->first.min_price.base.asset_id != o.sell_price.base.asset_id
|
||||
|| itr->first.min_price.quote.asset_id != o.sell_price.quote.asset_id )
|
||||
// not same market or group type
|
||||
create_ogo();
|
||||
else // same market and group type
|
||||
{
|
||||
// due to lower_bound, always true: capped_price < itr->first.min_price, so no need to check again,
|
||||
// if new order is in range of itr group, always need to update itr->first.min_price, unless
|
||||
// o.sell_price is higher than max
|
||||
price min_price = itr->second.max_price / ratio_type( GRAPHENE_100_PERCENT + group, GRAPHENE_100_PERCENT );
|
||||
// min_price should have been capped here
|
||||
if( capped_price < min_price ) // new order is out of range
|
||||
create_ogo();
|
||||
else if( capped_max && o.sell_price >= itr->first.min_price )
|
||||
{ // itr is above max, and price of new order is even higher
|
||||
if( o.sell_price > itr->second.max_price )
|
||||
itr->second.max_price = o.sell_price;
|
||||
itr->second.total_for_sale += o.for_sale;
|
||||
}
|
||||
else
|
||||
{ // new order is within the range
|
||||
// TODO improve performance
|
||||
limit_order_group_data data( itr->second.max_price, o.for_sale + itr->second.total_for_sale );
|
||||
idx.erase( itr );
|
||||
idx[ limit_order_group_key( group, o.sell_price ) ] = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW( (objct) ); }
|
||||
|
||||
void limit_order_group_index::object_removed( const object& objct )
|
||||
{ try {
|
||||
const limit_order_object& o = static_cast<const limit_order_object&>( objct );
|
||||
remove_order( o );
|
||||
} FC_CAPTURE_AND_RETHROW( (objct) ); }
|
||||
|
||||
void limit_order_group_index::about_to_modify( const object& objct )
|
||||
{ try {
|
||||
const limit_order_object& o = static_cast<const limit_order_object&>( objct );
|
||||
remove_order( o, false );
|
||||
} FC_CAPTURE_AND_RETHROW( (objct) ); }
|
||||
|
||||
void limit_order_group_index::object_modified( const object& objct )
|
||||
{ try {
|
||||
object_inserted( objct );
|
||||
} FC_CAPTURE_AND_RETHROW( (objct) ); }
|
||||
|
||||
void limit_order_group_index::remove_order( const limit_order_object& o, bool remove_empty )
|
||||
{
|
||||
auto& idx = _og_data;
|
||||
|
||||
for( uint16_t group : get_tracked_groups() )
|
||||
{
|
||||
// find the group that should contain this order
|
||||
auto itr = idx.lower_bound( limit_order_group_key( group, o.sell_price ) );
|
||||
if( itr == idx.end() || itr->first.group != group
|
||||
|| itr->first.min_price.base.asset_id != o.sell_price.base.asset_id
|
||||
|| itr->first.min_price.quote.asset_id != o.sell_price.quote.asset_id
|
||||
|| itr->second.max_price < o.sell_price )
|
||||
{
|
||||
// can not find corresponding group, should not happen
|
||||
wlog( "can not find the order group containing order for removing (price dismatch): ${o}", ("o",o) );
|
||||
continue;
|
||||
}
|
||||
else // found
|
||||
{
|
||||
if( itr->second.total_for_sale < o.for_sale )
|
||||
// should not happen
|
||||
wlog( "can not find the order group containing order for removing (amount dismatch): ${o}", ("o",o) );
|
||||
else if( !remove_empty || itr->second.total_for_sale > o.for_sale )
|
||||
itr->second.total_for_sale -= o.for_sale;
|
||||
else
|
||||
// it's the only order in the group and need to be removed
|
||||
idx.erase( itr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grouped_orders_plugin_impl::~grouped_orders_plugin_impl()
|
||||
{}
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
|
||||
grouped_orders_plugin::grouped_orders_plugin() :
|
||||
my( new detail::grouped_orders_plugin_impl(*this) )
|
||||
{
|
||||
}
|
||||
|
||||
grouped_orders_plugin::~grouped_orders_plugin()
|
||||
{
|
||||
}
|
||||
|
||||
std::string grouped_orders_plugin::plugin_name()const
|
||||
{
|
||||
return "grouped_orders";
|
||||
}
|
||||
|
||||
void grouped_orders_plugin::plugin_set_program_options(
|
||||
boost::program_options::options_description& cli,
|
||||
boost::program_options::options_description& cfg
|
||||
)
|
||||
{
|
||||
cli.add_options()
|
||||
("tracked-groups", boost::program_options::value<string>()->default_value("[10,100]"), // 0.1% and 1%
|
||||
"Group orders by percentage increase on price. Specify a JSON array of numbers here, each number is a group, number 1 means 0.01%. ")
|
||||
;
|
||||
cfg.add(cli);
|
||||
}
|
||||
|
||||
void grouped_orders_plugin::plugin_initialize(const boost::program_options::variables_map& options)
|
||||
{ try {
|
||||
|
||||
if( options.count( "tracked-groups" ) )
|
||||
{
|
||||
const std::string& groups = options["tracked-groups"].as<string>();
|
||||
my->_tracked_groups = fc::json::from_string(groups).as<flat_set<uint16_t>>( 2 );
|
||||
my->_tracked_groups.erase( 0 );
|
||||
}
|
||||
else
|
||||
my->_tracked_groups = fc::json::from_string("[10,100]").as<flat_set<uint16_t>>(2);
|
||||
|
||||
database().add_secondary_index< primary_index<limit_order_index>, detail::limit_order_group_index >( my->_tracked_groups );
|
||||
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
void grouped_orders_plugin::plugin_startup()
|
||||
{
|
||||
}
|
||||
|
||||
const flat_set<uint16_t>& grouped_orders_plugin::tracked_groups() const
|
||||
{
|
||||
return my->_tracked_groups;
|
||||
}
|
||||
|
||||
const map< limit_order_group_key, limit_order_group_data >& grouped_orders_plugin::limit_order_groups()
|
||||
{
|
||||
const auto& idx = database().get_index_type< limit_order_index >();
|
||||
const auto& pidx = dynamic_cast<const primary_index< limit_order_index >&>(idx);
|
||||
const auto& logidx = pidx.get_secondary_index< detail::limit_order_group_index >();
|
||||
return logidx.get_order_groups();
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
@ -4,7 +4,7 @@ add_library( graphene_market_history
|
|||
market_history_plugin.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_market_history graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_market_history PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_market_history
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ endif()
|
|||
unset(ENABLE_PEERPLAYS_ASSET_DEPOSITS)
|
||||
unset(ENABLE_PEERPLAYS_ASSET_DEPOSITS CACHE)
|
||||
|
||||
target_link_libraries( peerplays_sidechain graphene_chain graphene_app fc zmq )
|
||||
target_link_libraries( peerplays_sidechain PRIVATE graphene_plugin zmq )
|
||||
target_include_directories( peerplays_sidechain
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_snapshot
|
|||
snapshot.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_snapshot graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_snapshot PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_snapshot
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ add_library( graphene_witness
|
|||
witness.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( graphene_witness graphene_chain graphene_app )
|
||||
target_link_libraries( graphene_witness PRIVATE graphene_plugin )
|
||||
target_include_directories( graphene_witness
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ else()
|
|||
endif()
|
||||
|
||||
add_library( graphene_wallet wallet.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} )
|
||||
target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( graphene_wallet PRIVATE graphene_app )
|
||||
target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
if(MSVC)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
add_subdirectory( build_helpers )
|
||||
if( BUILD_BITSHARES_PROGRAMS )
|
||||
if( BUILD_PEERPLAYS_PROGRAMS )
|
||||
add_subdirectory( cli_wallet )
|
||||
add_subdirectory( genesis_util )
|
||||
add_subdirectory( witness_node )
|
||||
|
|
@ -7,4 +7,4 @@ if( BUILD_BITSHARES_PROGRAMS )
|
|||
add_subdirectory( delayed_node )
|
||||
add_subdirectory( js_operation_serializer )
|
||||
add_subdirectory( size_checker )
|
||||
endif( BUILD_BITSHARES_PROGRAMS )
|
||||
endif( BUILD_PEERPLAYS_PROGRAMS )
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
# we only actually need Boost, but link against FC for now so we don't duplicate it.
|
||||
target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( cat-parts PRIVATE fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
add_executable( member_enumerator member_enumerator.cpp )
|
||||
if( UNIX AND NOT APPLE )
|
||||
|
|
@ -13,5 +13,5 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
# we only actually need Boost, but link against FC for now so we don't duplicate it.
|
||||
target_link_libraries( member_enumerator PRIVATE fc graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( member_enumerator PRIVATE graphene_chain ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if( GPERFTOOLS_FOUND )
|
|||
endif()
|
||||
|
||||
target_link_libraries( cli_wallet
|
||||
PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_brief graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_brief graphene_wallet ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
if(MSVC)
|
||||
set_source_files_properties( main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if( GPERFTOOLS_FOUND )
|
|||
endif()
|
||||
|
||||
target_link_libraries( debug_node
|
||||
PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_debug_witness graphene_bookie graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_full ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
debug_node
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if( GPERFTOOLS_FOUND )
|
|||
endif()
|
||||
|
||||
target_link_libraries( delayed_node
|
||||
PRIVATE graphene_app graphene_account_history graphene_market_history graphene_delayed_node graphene_chain graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_full graphene_delayed_node ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
delayed_node
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
target_link_libraries( genesis_update
|
||||
PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_none ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
genesis_update
|
||||
|
|
@ -18,7 +18,7 @@ install( TARGETS
|
|||
add_executable( get_dev_key get_dev_key.cpp )
|
||||
|
||||
target_link_libraries( get_dev_key
|
||||
PRIVATE graphene_app graphene_chain graphene_egenesis_none graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
get_dev_key
|
||||
|
|
@ -31,4 +31,4 @@ install( TARGETS
|
|||
add_executable( convert_address convert_address.cpp )
|
||||
|
||||
target_link_libraries( convert_address
|
||||
PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_chain ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
target_link_libraries( js_operation_serializer
|
||||
PRIVATE graphene_app graphene_net graphene_chain graphene_egenesis_none graphene_utilities graphene_wallet fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
js_operation_serializer
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
target_link_libraries( size_checker
|
||||
PRIVATE graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_chain ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
size_checker
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ endif()
|
|||
|
||||
# We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246
|
||||
target_link_libraries( witness_node
|
||||
PRIVATE graphene_app graphene_account_history graphene_affiliate_stats graphene_elasticsearch graphene_market_history graphene_witness graphene_chain graphene_debug_witness graphene_bookie graphene_egenesis_full graphene_snapshot graphene_es_objects fc peerplays_sidechain ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_full graphene_snapshot graphene_witness peerplays_sidechain ${PLATFORM_SPECIFIC_LIBS} )
|
||||
# also add dependencies to graphene_generate_genesis graphene_generate_uia_sharedrop_genesis if you want those plugins
|
||||
|
||||
install( TARGETS
|
||||
|
|
|
|||
|
|
@ -1,62 +1,65 @@
|
|||
file(GLOB COMMON_SOURCES "common/*.cpp")
|
||||
|
||||
find_package( Gperftools QUIET )
|
||||
if( GPERFTOOLS_FOUND )
|
||||
message( STATUS "Found gperftools; compiling tests with TCMalloc")
|
||||
list( APPEND PLATFORM_SPECIFIC_LIBS tcmalloc )
|
||||
endif()
|
||||
|
||||
file(GLOB COMMON_SOURCES "common/*.cpp")
|
||||
add_library(graphene_tests_common "${COMMON_SOURCES}" )
|
||||
target_link_libraries( graphene_tests_common
|
||||
PUBLIC graphene_app graphene_egenesis_none )
|
||||
|
||||
file(GLOB UNIT_TESTS "tests/*.cpp")
|
||||
add_executable( chain_test ${UNIT_TESTS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( chain_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_bookie graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( chain_test ${UNIT_TESTS} )
|
||||
target_link_libraries( chain_test PRIVATE graphene_wallet graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
if(MSVC)
|
||||
set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||
endif(MSVC)
|
||||
|
||||
file(GLOB PERFORMANCE_TESTS "performance/*.cpp")
|
||||
add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_bookie graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( performance_test ${PERFORMANCE_TESTS} )
|
||||
target_link_libraries( performance_test PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB BENCH_MARKS "benchmarks/*.cpp")
|
||||
add_executable( chain_bench ${BENCH_MARKS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_bookie graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( chain_bench ${BENCH_MARKS} )
|
||||
target_link_libraries( chain_bench PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB APP_SOURCES "app/*.cpp")
|
||||
add_executable( app_test ${APP_SOURCES} )
|
||||
target_link_libraries( app_test graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_witness graphene_bookie graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( app_test PRIVATE graphene_tests_common graphene_witness ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB INTENSE_SOURCES "intense/*.cpp")
|
||||
add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} )
|
||||
target_link_libraries( intense_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_bookie graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( intense_test ${INTENSE_SOURCES} )
|
||||
target_link_libraries( intense_test PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB BETTING_TESTS "betting/*.cpp")
|
||||
add_executable( betting_test ${BETTING_TESTS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( betting_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_bookie graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( betting_test ${BETTING_TESTS} )
|
||||
target_link_libraries( betting_test PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB PEERPLAYS_SIDECHAIN_TESTS "peerplays_sidechain/*.cpp")
|
||||
add_executable( peerplays_sidechain_test ${PEERPLAYS_SIDECHAIN_TESTS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( peerplays_sidechain_test graphene_chain graphene_app graphene_account_history graphene_bookie graphene_elasticsearch graphene_es_objects graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( peerplays_sidechain_test ${PEERPLAYS_SIDECHAIN_TESTS} )
|
||||
target_link_libraries( peerplays_sidechain_test PRIVATE graphene_tests_common peerplays_sidechain ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB TOURNAMENT_TESTS "tournament/*.cpp")
|
||||
add_executable( tournament_test ${TOURNAMENT_TESTS} ${COMMON_SOURCES} )
|
||||
target_link_libraries( tournament_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( tournament_test ${TOURNAMENT_TESTS} )
|
||||
target_link_libraries( tournament_test PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB RANDOM_SOURCES "random/*.cpp")
|
||||
add_executable( random_test ${RANDOM_SOURCES} ${COMMON_SOURCES} )
|
||||
target_link_libraries( random_test graphene_chain graphene_app graphene_elasticsearch graphene_es_objects graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( random_test ${RANDOM_SOURCES} )
|
||||
target_link_libraries( random_test PRIVATE graphene_tests_common ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
file(GLOB CLI_SOURCES "cli/*.cpp")
|
||||
add_executable( cli_test ${CLI_SOURCES} )
|
||||
if(WIN32)
|
||||
list(APPEND PLATFORM_SPECIFIC_LIBS ws2_32)
|
||||
endif()
|
||||
target_link_libraries( cli_test graphene_chain graphene_app graphene_witness graphene_wallet graphene_egenesis_none fc graphene_elasticsearch graphene_es_objects ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( cli_test PRIVATE graphene_wallet graphene_tests_common graphene_witness ${PLATFORM_SPECIFIC_LIBS} )
|
||||
if(MSVC)
|
||||
set_source_files_properties( cli/main.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
|
||||
endif(MSVC)
|
||||
|
||||
file(GLOB ES_SOURCES "elasticsearch/*.cpp")
|
||||
add_executable( es_test ${ES_SOURCES} ${COMMON_SOURCES} )
|
||||
target_link_libraries( es_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_es_objects graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} )
|
||||
add_executable( es_test ${ES_SOURCES} )
|
||||
target_link_libraries( es_test PRIVATE graphene_tests_common )
|
||||
|
||||
add_subdirectory( generate_empty_blocks )
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if( UNIX AND NOT APPLE )
|
|||
endif()
|
||||
|
||||
target_link_libraries( generate_empty_blocks
|
||||
PRIVATE graphene_app graphene_chain graphene_egenesis_none fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
PRIVATE graphene_app graphene_egenesis_none ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
||||
install( TARGETS
|
||||
generate_empty_blocks
|
||||
|
|
|
|||
Loading…
Reference in a new issue