Add cmake flag to determine testnet vs mainnet build

This commit is contained in:
serkixenos 2021-12-02 02:06:38 +00:00
parent 92e017e3b0
commit 727d54feb0
54 changed files with 220280 additions and 4682 deletions

View file

@ -51,7 +51,15 @@ macro(FIND_CURL)
endmacro() 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" )
if (BUILD_PEERPLAYS_TESTNET)
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-testnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
add_compile_definitions(BUILD_PEERPLAYS_TESTNET=1)
message ("\n====================\nBuilding for Testnet\n====================\n")
else (BUILD_PEERPLAYS_TESTNET)
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis-mainnet.json" CACHE PATH "location of the genesis.json to embed in the executable" )
message ("\n====================\nBuilding for Mainnet\n====================\n")
endif (BUILD_PEERPLAYS_TESTNET)
#set (ENABLE_INSTALLER 1) #set (ENABLE_INSTALLER 1)
#set (USE_PCH 1) #set (USE_PCH 1)
@ -242,3 +250,7 @@ endif(LINUX)
include(CPack) include(CPack)
endif(ENABLE_INSTALLER) endif(ENABLE_INSTALLER)
unset(GRAPHENE_EGENESIS_JSON)
unset(GRAPHENE_EGENESIS_JSON CACHE)
unset(BUILD_PEERPLAYS_TESTNET)
unset(BUILD_PEERPLAYS_TESTNET CACHE)

View file

@ -38,7 +38,10 @@ export BOOST_ROOT=$HOME/src/boost_1_67_0
git clone https://github.com/peerplays-network/peerplays.git git clone https://github.com/peerplays-network/peerplays.git
cd peerplays cd peerplays
git submodule update --init --recursive git submodule update --init --recursive
# If you want to build Mainnet node
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release
# If you want to build Testnet node
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1
make -j$(nproc) make -j$(nproc)
make install # this can install the executable files under /usr/local make install # this can install the executable files under /usr/local

View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
find ./libraries/app -regex ".*[c|h]pp" | xargs clang-format -i
find ./libraries/chain/hardfork.d -regex ".*hf" | xargs clang-format -i
find ./libraries/plugins/peerplays_sidechain -regex ".*[c|h]pp" | xargs clang-format -i find ./libraries/plugins/peerplays_sidechain -regex ".*[c|h]pp" | xargs clang-format -i

216158
genesis-mainnet.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -55,4 +55,3 @@ INSTALL( TARGETS
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
) )

View file

@ -26,16 +26,16 @@
#include <graphene/app/api.hpp> #include <graphene/app/api.hpp>
#include <graphene/app/api_access.hpp> #include <graphene/app/api_access.hpp>
#include <graphene/app/application.hpp> #include <graphene/app/application.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/get_config.hpp> #include <graphene/chain/get_config.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/market_object.hpp> #include <graphene/chain/market_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/tournament_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>
#include <graphene/chain/worker_object.hpp> #include <graphene/chain/worker_object.hpp>
#include <graphene/chain/tournament_object.hpp> #include <graphene/utilities/key_conversion.hpp>
#include <fc/crypto/hex.hpp> #include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp> #include <fc/rpc/api_connection.hpp>
@ -50,25 +50,20 @@ template class fc::api<graphene::app::asset_api>;
template class fc::api<graphene::debug_witness::debug_api>; template class fc::api<graphene::debug_witness::debug_api>;
template class fc::api<graphene::app::login_api>; template class fc::api<graphene::app::login_api>;
namespace graphene { namespace app { namespace graphene { namespace app {
login_api::login_api(application& a) login_api::login_api(application &a) :
:_app(a) _app(a) {
{
} }
login_api::~login_api() login_api::~login_api() {
{
} }
bool login_api::login(const string& user, const string& password) bool login_api::login(const string &user, const string &password) {
{
optional<api_access_info> acc = _app.get_api_access_info(user); optional<api_access_info> acc = _app.get_api_access_info(user);
if (!acc.valid()) if (!acc.valid())
return false; return false;
if( acc->password_hash_b64 != "*" ) if (acc->password_hash_b64 != "*") {
{
std::string password_salt = fc::base64_decode(acc->password_salt_b64); std::string password_salt = fc::base64_decode(acc->password_salt_b64);
std::string acc_password_hash = fc::base64_decode(acc->password_hash_b64); std::string acc_password_hash = fc::base64_decode(acc->password_hash_b64);
@ -84,50 +79,30 @@ namespace graphene { namespace app {
return true; return true;
} }
void login_api::enable_api( const std::string& api_name ) void login_api::enable_api(const std::string &api_name) {
{ if (api_name == "database_api") {
if( api_name == "database_api" )
{
_database_api = std::make_shared<database_api>(std::ref(*_app.chain_database())); _database_api = std::make_shared<database_api>(std::ref(*_app.chain_database()));
} } else if (api_name == "block_api") {
else if( api_name == "block_api" )
{
_block_api = std::make_shared<block_api>(std::ref(*_app.chain_database())); _block_api = std::make_shared<block_api>(std::ref(*_app.chain_database()));
} } else if (api_name == "network_broadcast_api") {
else if( api_name == "network_broadcast_api" )
{
_network_broadcast_api = std::make_shared<network_broadcast_api>(std::ref(_app)); _network_broadcast_api = std::make_shared<network_broadcast_api>(std::ref(_app));
} } else if (api_name == "history_api") {
else if( api_name == "history_api" )
{
_history_api = std::make_shared<history_api>(_app); _history_api = std::make_shared<history_api>(_app);
} } else if (api_name == "network_node_api") {
else if( api_name == "network_node_api" )
{
_network_node_api = std::make_shared<network_node_api>(std::ref(_app)); _network_node_api = std::make_shared<network_node_api>(std::ref(_app));
} } else if (api_name == "crypto_api") {
else if( api_name == "crypto_api" )
{
_crypto_api = std::make_shared<crypto_api>(); _crypto_api = std::make_shared<crypto_api>();
} } else if (api_name == "asset_api") {
else if( api_name == "asset_api" )
{
_asset_api = std::make_shared<asset_api>(_app); _asset_api = std::make_shared<asset_api>(_app);
} } else if (api_name == "debug_api") {
else if( api_name == "debug_api" )
{
// can only enable this API if the plugin was loaded // can only enable this API if the plugin was loaded
if (_app.get_plugin("debug_witness")) if (_app.get_plugin("debug_witness"))
_debug_api = std::make_shared<graphene::debug_witness::debug_api>(std::ref(_app)); _debug_api = std::make_shared<graphene::debug_witness::debug_api>(std::ref(_app));
} } else if (api_name == "bookie_api") {
else if( api_name == "bookie_api" )
{
// can only enable this API if the plugin was loaded // can only enable this API if the plugin was loaded
if (_app.get_plugin("bookie")) if (_app.get_plugin("bookie"))
_bookie_api = std::make_shared<graphene::bookie::bookie_api>(std::ref(_app)); _bookie_api = std::make_shared<graphene::bookie::bookie_api>(std::ref(_app));
} } else if (api_name == "affiliate_stats_api") {
else if( api_name == "affiliate_stats_api" )
{
// can only enable this API if the plugin was loaded // can only enable this API if the plugin was loaded
if (_app.get_plugin("affiliate_stats")) if (_app.get_plugin("affiliate_stats"))
_affiliate_stats_api = std::make_shared<graphene::affiliate_stats::affiliate_stats_api>(std::ref(_app)); _affiliate_stats_api = std::make_shared<graphene::affiliate_stats::affiliate_stats_api>(std::ref(_app));
@ -136,11 +111,13 @@ namespace graphene { namespace app {
} }
// block_api // block_api
block_api::block_api(graphene::chain::database& db) : _db(db) { } block_api::block_api(graphene::chain::database &db) :
block_api::~block_api() { } _db(db) {
}
block_api::~block_api() {
}
vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to)const vector<optional<signed_block>> block_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const {
{
FC_ASSERT(block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100"); FC_ASSERT(block_num_to >= block_num_from && block_num_to - block_num_from <= 100, "Total blocks to be returned should be less than 100");
vector<optional<signed_block>> res; vector<optional<signed_block>> res;
for (uint32_t block_num = block_num_from; block_num <= block_num_to; block_num++) { for (uint32_t block_num = block_num_from; block_num <= block_num_to; block_num++) {
@ -149,24 +126,22 @@ namespace graphene { namespace app {
return res; return res;
} }
network_broadcast_api::network_broadcast_api(application& a):_app(a) network_broadcast_api::network_broadcast_api(application &a) :
{ _app(a) {
_applied_block_connection = _app.chain_database()->applied_block.connect([this](const signed_block& b){ on_applied_block(b); }); _applied_block_connection = _app.chain_database()->applied_block.connect([this](const signed_block &b) {
on_applied_block(b);
});
} }
void network_broadcast_api::on_applied_block( const signed_block& b ) void network_broadcast_api::on_applied_block(const signed_block &b) {
{ if (_callbacks.size()) {
if( _callbacks.size() )
{
/// we need to ensure the database_api is not deleted for the life of the async operation /// we need to ensure the database_api is not deleted for the life of the async operation
auto capture_this = shared_from_this(); auto capture_this = shared_from_this();
for( uint32_t trx_num = 0; trx_num < b.transactions.size(); ++trx_num ) for (uint32_t trx_num = 0; trx_num < b.transactions.size(); ++trx_num) {
{
const auto &trx = b.transactions[trx_num]; const auto &trx = b.transactions[trx_num];
auto id = trx.id(); auto id = trx.id();
auto itr = _callbacks.find(id); auto itr = _callbacks.find(id);
if( itr != _callbacks.end() ) if (itr != _callbacks.end()) {
{
auto block_num = b.block_num(); auto block_num = b.block_num();
auto &callback = _callbacks.find(id)->second; auto &callback = _callbacks.find(id)->second;
fc::async([capture_this, this, id, block_num, trx_num, trx, callback]() { fc::async([capture_this, this, id, block_num, trx_num, trx, callback]() {
@ -178,8 +153,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_transaction_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);
@ -187,27 +161,25 @@ namespace graphene { namespace app {
_app.p2p_node()->broadcast_transaction(trx); _app.p2p_node()->broadcast_transaction(trx);
} }
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_transaction_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) {
prom->set_value(v); prom->set_value(v);
}, trx ); },
trx);
return fc::future<fc::variant>(prom).wait(); return fc::future<fc::variant>(prom).wait();
} }
void network_broadcast_api::broadcast_block( const signed_block& b ) void network_broadcast_api::broadcast_block(const signed_block &b) {
{
_app.chain_database()->push_block(b); _app.chain_database()->push_block(b);
if (_app.p2p_node() != nullptr) if (_app.p2p_node() != nullptr)
_app.p2p_node()->broadcast(net::block_message(b)); _app.p2p_node()->broadcast(net::block_message(b));
} }
void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction& trx) void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction &trx) {
{
trx.validate(); trx.validate();
_callbacks[trx.id()] = cb; _callbacks[trx.id()] = cb;
_app.chain_database()->push_transaction(trx); _app.chain_database()->push_transaction(trx);
@ -215,28 +187,23 @@ namespace graphene { namespace app {
_app.p2p_node()->broadcast_transaction(trx); _app.p2p_node()->broadcast_transaction(trx);
} }
network_node_api::network_node_api( application& a ) : _app( a ) network_node_api::network_node_api(application &a) :
{ _app(a) {
_pending_trx_connection = _app.chain_database()->on_pending_transaction.connect([this](const signed_transaction &transaction) { _pending_trx_connection = _app.chain_database()->on_pending_transaction.connect([this](const signed_transaction &transaction) {
auto transaction_it = _pending_transactions.find(transaction.id()); auto transaction_it = _pending_transactions.find(transaction.id());
if (_pending_transactions.end() == transaction_it) if (_pending_transactions.end() == transaction_it) {
{
_pending_transactions[transaction.id()] = transaction; _pending_transactions[transaction.id()] = transaction;
} }
if (_on_pending_transaction) if (_on_pending_transaction) {
{
_on_pending_transaction(fc::variant(transaction, GRAPHENE_MAX_NESTED_OBJECTS)); _on_pending_transaction(fc::variant(transaction, GRAPHENE_MAX_NESTED_OBJECTS));
} }
}); });
_applied_block_connection = _app.chain_database()->applied_block.connect([this](const signed_block &block) { _applied_block_connection = _app.chain_database()->applied_block.connect([this](const signed_block &block) {
for (const auto& transaction: block.transactions) for (const auto &transaction : block.transactions) {
{
auto transaction_it = _pending_transactions.find(transaction.id()); auto transaction_it = _pending_transactions.find(transaction.id());
if (_pending_transactions.end() != transaction_it) if (_pending_transactions.end() != transaction_it) {
{
_pending_transactions.erase(transaction_it); _pending_transactions.erase(transaction_it);
} }
} }
@ -244,13 +211,10 @@ namespace graphene { namespace app {
/* /*
* Remove expired transactions from pending_transactions * Remove expired transactions from pending_transactions
*/ */
for (const auto& transaction: _pending_transactions) for (const auto &transaction : _pending_transactions) {
{ if (transaction.second.expiration < block.timestamp) {
if (transaction.second.expiration < block.timestamp)
{
auto transaction_it = _pending_transactions.find(transaction.second.id()); auto transaction_it = _pending_transactions.find(transaction.second.id());
if (_pending_transactions.end() != transaction_it) if (_pending_transactions.end() != transaction_it) {
{
_pending_transactions.erase(transaction_it); _pending_transactions.erase(transaction_it);
} }
} }
@ -258,300 +222,101 @@ namespace graphene { namespace app {
}); });
} }
fc::variant_object network_node_api::get_info() const fc::variant_object network_node_api::get_info() const {
{
fc::mutable_variant_object result = _app.p2p_node()->network_get_info(); fc::mutable_variant_object result = _app.p2p_node()->network_get_info();
result["connection_count"] = _app.p2p_node()->get_connection_count(); result["connection_count"] = _app.p2p_node()->get_connection_count();
return result; return result;
} }
void network_node_api::add_node(const fc::ip::endpoint& ep) void network_node_api::add_node(const fc::ip::endpoint &ep) {
{
_app.p2p_node()->add_node(ep); _app.p2p_node()->add_node(ep);
} }
std::vector<net::peer_status> network_node_api::get_connected_peers() const std::vector<net::peer_status> network_node_api::get_connected_peers() const {
{
return _app.p2p_node()->get_connected_peers(); return _app.p2p_node()->get_connected_peers();
} }
std::vector<net::potential_peer_record> network_node_api::get_potential_peers() const std::vector<net::potential_peer_record> network_node_api::get_potential_peers() const {
{
return _app.p2p_node()->get_potential_peers(); return _app.p2p_node()->get_potential_peers();
} }
fc::variant_object network_node_api::get_advanced_node_parameters() const fc::variant_object network_node_api::get_advanced_node_parameters() const {
{
return _app.p2p_node()->get_advanced_node_parameters(); return _app.p2p_node()->get_advanced_node_parameters();
} }
void network_node_api::set_advanced_node_parameters(const fc::variant_object& params) void network_node_api::set_advanced_node_parameters(const fc::variant_object &params) {
{
return _app.p2p_node()->set_advanced_node_parameters(params); return _app.p2p_node()->set_advanced_node_parameters(params);
} }
map<transaction_id_type, signed_transaction> network_node_api::list_pending_transactions() const map<transaction_id_type, signed_transaction> network_node_api::list_pending_transactions() const {
{
return _pending_transactions; return _pending_transactions;
} }
void network_node_api::subscribe_to_pending_transactions( std::function<void(const variant&)> callback ) void network_node_api::subscribe_to_pending_transactions(std::function<void(const variant &)> callback) {
{
_on_pending_transaction = callback; _on_pending_transaction = callback;
} }
void network_node_api::unsubscribe_from_pending_transactions() void network_node_api::unsubscribe_from_pending_transactions() {
{
_on_pending_transaction = std::function<void(const variant &)>(); _on_pending_transaction = std::function<void(const variant &)>();
} }
fc::api<network_broadcast_api> login_api::network_broadcast()const fc::api<network_broadcast_api> login_api::network_broadcast() const {
{
FC_ASSERT(_network_broadcast_api); FC_ASSERT(_network_broadcast_api);
return *_network_broadcast_api; return *_network_broadcast_api;
} }
fc::api<block_api> login_api::block()const fc::api<block_api> login_api::block() const {
{
FC_ASSERT(_block_api); FC_ASSERT(_block_api);
return *_block_api; return *_block_api;
} }
fc::api<network_node_api> login_api::network_node()const fc::api<network_node_api> login_api::network_node() const {
{
FC_ASSERT(_network_node_api); FC_ASSERT(_network_node_api);
return *_network_node_api; return *_network_node_api;
} }
fc::api<database_api> login_api::database()const fc::api<database_api> login_api::database() const {
{
FC_ASSERT(_database_api); FC_ASSERT(_database_api);
return *_database_api; return *_database_api;
} }
fc::api<history_api> login_api::history() const fc::api<history_api> login_api::history() const {
{
FC_ASSERT(_history_api); FC_ASSERT(_history_api);
return *_history_api; return *_history_api;
} }
fc::api<crypto_api> login_api::crypto() const fc::api<crypto_api> login_api::crypto() const {
{
FC_ASSERT(_crypto_api); FC_ASSERT(_crypto_api);
return *_crypto_api; return *_crypto_api;
} }
fc::api<asset_api> login_api::asset() const fc::api<asset_api> login_api::asset() const {
{
FC_ASSERT(_asset_api); FC_ASSERT(_asset_api);
return *_asset_api; return *_asset_api;
} }
fc::api<graphene::debug_witness::debug_api> login_api::debug() const fc::api<graphene::debug_witness::debug_api> login_api::debug() const {
{
FC_ASSERT(_debug_api); FC_ASSERT(_debug_api);
return *_debug_api; return *_debug_api;
} }
fc::api<graphene::bookie::bookie_api> login_api::bookie() const fc::api<graphene::bookie::bookie_api> login_api::bookie() const {
{
FC_ASSERT(_bookie_api); FC_ASSERT(_bookie_api);
return *_bookie_api; return *_bookie_api;
} }
fc::api<graphene::affiliate_stats::affiliate_stats_api> login_api::affiliate_stats() const fc::api<graphene::affiliate_stats::affiliate_stats_api> login_api::affiliate_stats() const {
{
FC_ASSERT(_affiliate_stats_api); FC_ASSERT(_affiliate_stats_api);
return *_affiliate_stats_api; return *_affiliate_stats_api;
} }
#if 0 vector<order_history_object> history_api::get_fill_order_history(std::string asset_a, std::string asset_b, uint32_t limit) const {
vector<account_id_type> get_relevant_accounts( const object* obj )
{
vector<account_id_type> result;
if( obj->id.space() == protocol_ids )
{
switch( (object_type)obj->id.type() )
{
case null_object_type:
case base_object_type:
case OBJECT_TYPE_COUNT:
return result;
case account_object_type:{
result.push_back( obj->id );
break;
} case asset_object_type:{
const auto& aobj = dynamic_cast<const asset_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->issuer );
break;
} case force_settlement_object_type:{
const auto& aobj = dynamic_cast<const force_settlement_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->owner );
break;
} case committee_member_object_type:{
const auto& aobj = dynamic_cast<const committee_member_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->committee_member_account );
break;
} case witness_object_type:{
const auto& aobj = dynamic_cast<const witness_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->witness_account );
break;
} case limit_order_object_type:{
const auto& aobj = dynamic_cast<const limit_order_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->seller );
break;
} case call_order_object_type:{
const auto& aobj = dynamic_cast<const call_order_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->borrower );
break;
} case custom_object_type:{
break;
} case proposal_object_type:{
const auto& aobj = dynamic_cast<const proposal_object*>(obj);
assert( aobj != nullptr );
flat_set<account_id_type> impacted;
transaction_get_impacted_accounts( aobj->proposed_transaction, impacted );
result.reserve( impacted.size() );
for( auto& item : impacted ) result.emplace_back(item);
break;
} case operation_history_object_type:{
const auto& aobj = dynamic_cast<const operation_history_object*>(obj);
assert( aobj != nullptr );
flat_set<account_id_type> impacted;
operation_get_impacted_accounts( aobj->op, impacted );
result.reserve( impacted.size() );
for( auto& item : impacted ) result.emplace_back(item);
break;
} case withdraw_permission_object_type:{
const auto& aobj = dynamic_cast<const withdraw_permission_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->withdraw_from_account );
result.push_back( aobj->authorized_account );
break;
} case vesting_balance_object_type:{
const auto& aobj = dynamic_cast<const vesting_balance_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->owner );
break;
} case worker_object_type:{
const auto& aobj = dynamic_cast<const worker_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->worker_account );
break;
} case balance_object_type:{
/** these are free from any accounts */
break;
} case son_object_type:{
const auto& aobj = dynamic_cast<const son_object*>(obj);
assert( aobj != nullptr );
accounts.insert( aobj->son_account );
break;
} case sidechain_address_object_type:{
const auto& aobj = dynamic_cast<const sidechain_address_object*>(obj);
assert( aobj != nullptr );
accounts.insert( aobj->sidechain_address_account );
break;
}
case sport_object_type:
case event_group_object_type:
case event_object_type:
case betting_market_group_object_type:
case betting_market_object_type:
/** these are free from any accounts */
break;
case bet_object_type:{
const auto& aobj = dynamic_cast<const bet_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->bettor_id );
} case tournament_object_type:{
const tournament_object* tournament_obj = dynamic_cast<const tournament_object*>(obj);
assert(tournament_obj);
const tournament_details_object& details = tournament_obj->tournament_details_id(*_app.chain_database());
flat_set<account_id_type> impacted = details.registered_players;
impacted.insert(tournament_obj->creator);
std::copy(impacted.begin(), impacted.end(), std::back_inserter(result));
break;
}
}
}
else if( obj->id.space() == implementation_ids )
{
switch( (impl_object_type)obj->id.type() )
{
case impl_global_property_object_type:
break;
case impl_dynamic_global_property_object_type:
break;
case impl_reserved0_object_type:
break;
case impl_asset_dynamic_data_type:
break;
case impl_asset_bitasset_data_type:
break;
case impl_account_balance_object_type:{
const auto& aobj = dynamic_cast<const account_balance_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->owner );
break;
} case impl_account_statistics_object_type:{
const auto& aobj = dynamic_cast<const account_statistics_object*>(obj);
assert( aobj != nullptr );
result.push_back( aobj->owner );
break;
} case impl_transaction_object_type:{
const auto& aobj = dynamic_cast<const transaction_object*>(obj);
assert( aobj != nullptr );
flat_set<account_id_type> impacted;
transaction_get_impacted_accounts( aobj->trx, impacted );
result.reserve( impacted.size() );
for( auto& item : impacted ) result.emplace_back(item);
break;
} case impl_blinded_balance_object_type:{
const auto& aobj = dynamic_cast<const blinded_balance_object*>(obj);
assert( aobj != nullptr );
result.reserve( aobj->owner.account_auths.size() );
for( const auto& a : aobj->owner.account_auths )
result.push_back( a.first );
break;
} case impl_block_summary_object_type:
break;
case impl_account_transaction_history_object_type:
break;
case impl_chain_property_object_type:
break;
case impl_witness_schedule_object_type:
break;
case impl_budget_record_object_type:
break;
case impl_special_authority_object_type:
break;
case impl_buyback_object_type:
break;
case impl_fba_accumulator_object_type:
break;
case impl_betting_market_position_object_type:
break;
case impl_global_betting_statistics_object_type:
break;
}
}
return result;
} // end get_relevant_accounts( obj )
#endif
vector<order_history_object> history_api::get_fill_order_history( std::string asset_a, std::string asset_b, uint32_t limit )const
{
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
asset_id_type a = database_api.get_asset_id_from_string(asset_a); asset_id_type a = database_api.get_asset_id_from_string(asset_a);
asset_id_type b = database_api.get_asset_id_from_string(asset_b); asset_id_type b = database_api.get_asset_id_from_string(asset_b);
if( a > b ) std::swap(a,b); if (a > b)
std::swap(a, b);
const auto &history_idx = db.get_index_type<graphene::market_history::history_index>().indices().get<by_key>(); const auto &history_idx = db.get_index_type<graphene::market_history::history_index>().indices().get<by_key>();
history_key hkey; history_key hkey;
hkey.base = a; hkey.base = a;
@ -561,9 +326,9 @@ namespace graphene { namespace app {
uint32_t count = 0; uint32_t count = 0;
auto itr = history_idx.lower_bound(hkey); auto itr = history_idx.lower_bound(hkey);
vector<order_history_object> result; vector<order_history_object> result;
while( itr != history_idx.end() && count < limit) while (itr != history_idx.end() && count < limit) {
{ if (itr->key.base != a || itr->key.quote != b)
if( itr->key.base != a || itr->key.quote != b ) break; break;
result.push_back(*itr); result.push_back(*itr);
++itr; ++itr;
++count; ++count;
@ -575,8 +340,7 @@ namespace graphene { namespace app {
vector<operation_history_object> history_api::get_account_history(const std::string account_id_or_name, vector<operation_history_object> history_api::get_account_history(const std::string account_id_or_name,
operation_history_id_type stop, operation_history_id_type stop,
unsigned limit, unsigned limit,
operation_history_id_type start ) const operation_history_id_type start) const {
{
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
FC_ASSERT(limit <= api_limit_get_account_history, FC_ASSERT(limit <= api_limit_get_account_history,
@ -590,7 +354,9 @@ namespace graphene { namespace app {
const account_transaction_history_object &node = account(db).statistics(db).most_recent_op(db); const account_transaction_history_object &node = account(db).statistics(db).most_recent_op(db);
if (start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value) if (start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value)
start = node.operation_id; start = node.operation_id;
} catch(...) { return result; } } catch (...) {
return result;
}
if (_app.is_plugin_enabled("elasticsearch")) { if (_app.is_plugin_enabled("elasticsearch")) {
auto es = _app.get_plugin<elasticsearch::elasticsearch_plugin>("elasticsearch"); auto es = _app.get_plugin<elasticsearch::elasticsearch_plugin>("elasticsearch");
@ -600,7 +366,9 @@ namespace graphene { namespace app {
return _app.elasticsearch_thread->async([&es, &account, &stop, &limit, &start]() { return _app.elasticsearch_thread->async([&es, &account, &stop, &limit, &start]() {
return es->get_account_history(account, stop, limit, start); return es->get_account_history(account, stop, limit, start);
}, "thread invoke for method " BOOST_PP_STRINGIZE(method_name)).wait(); },
"thread invoke for method " BOOST_PP_STRINGIZE(method_name))
.wait();
} }
} }
@ -609,8 +377,7 @@ namespace graphene { namespace app {
auto index_start = by_op_idx.begin(); auto index_start = by_op_idx.begin();
auto itr = by_op_idx.lower_bound(boost::make_tuple(account, start)); auto itr = by_op_idx.lower_bound(boost::make_tuple(account, start));
while(itr != index_start && itr->account == account && itr->operation_id.instance.value > stop.instance.value && result.size() < limit) while (itr != index_start && itr->account == account && itr->operation_id.instance.value > stop.instance.value && result.size() < limit) {
{
if (itr->operation_id.instance.value <= start.instance.value) if (itr->operation_id.instance.value <= start.instance.value)
result.push_back(itr->operation_id(db)); result.push_back(itr->operation_id(db));
--itr; --itr;
@ -626,8 +393,7 @@ namespace graphene { namespace app {
int operation_id, int operation_id,
operation_history_id_type start, operation_history_id_type start,
operation_history_id_type stop, operation_history_id_type stop,
unsigned limit) const unsigned limit) const {
{
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
FC_ASSERT(limit <= api_limit_get_account_history_operations, FC_ASSERT(limit <= api_limit_get_account_history_operations,
@ -638,16 +404,18 @@ namespace graphene { namespace app {
account_id_type account; account_id_type account;
try { try {
account = database_api.get_account_id_from_string(account_id_or_name); account = database_api.get_account_id_from_string(account_id_or_name);
} catch (...) { return result; } } catch (...) {
return result;
}
const auto &stats = account(db).statistics(db); const auto &stats = account(db).statistics(db);
if( stats.most_recent_op == account_transaction_history_id_type() ) return result; if (stats.most_recent_op == account_transaction_history_id_type())
return result;
const account_transaction_history_object *node = &stats.most_recent_op(db); const account_transaction_history_object *node = &stats.most_recent_op(db);
if (start == operation_history_id_type()) if (start == operation_history_id_type())
start = node->operation_id; start = node->operation_id;
while(node && node->operation_id.instance.value > stop.instance.value && result.size() < limit) while (node && node->operation_id.instance.value > stop.instance.value && result.size() < limit) {
{
if (node->operation_id.instance.value <= start.instance.value) { if (node->operation_id.instance.value <= start.instance.value) {
if (node->operation_id(db).op.which() == operation_id) if (node->operation_id(db).op.which() == operation_id)
@ -655,7 +423,8 @@ namespace graphene { namespace app {
} }
if (node->next == account_transaction_history_id_type()) if (node->next == account_transaction_history_id_type())
node = nullptr; node = nullptr;
else node = &node->next(db); else
node = &node->next(db);
} }
if (stop.instance.value == 0 && result.size() < limit) { if (stop.instance.value == 0 && result.size() < limit) {
auto head = db.find(account_transaction_history_id_type()); auto head = db.find(account_transaction_history_id_type());
@ -665,12 +434,10 @@ namespace graphene { namespace app {
return result; return result;
} }
vector<operation_history_object> history_api::get_relative_account_history(const std::string account_id_or_name, vector<operation_history_object> history_api::get_relative_account_history(const std::string account_id_or_name,
uint32_t stop, uint32_t stop,
unsigned limit, unsigned limit,
uint32_t start) const uint32_t start) const {
{
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
FC_ASSERT(limit <= api_limit_get_relative_account_history, FC_ASSERT(limit <= api_limit_get_relative_account_history,
@ -681,49 +448,45 @@ namespace graphene { namespace app {
account_id_type account; account_id_type account;
try { try {
account = database_api.get_account_id_from_string(account_id_or_name); account = database_api.get_account_id_from_string(account_id_or_name);
} catch(...) { return result; } } catch (...) {
return result;
}
const auto &stats = account(db).statistics(db); const auto &stats = account(db).statistics(db);
if (start == 0) if (start == 0)
start = stats.total_ops; start = stats.total_ops;
else else
start = min(stats.total_ops, start); start = min(stats.total_ops, start);
if (start >= stop && start > stats.removed_ops && limit > 0) {
if( start >= stop && start > stats.removed_ops && limit > 0 )
{
const auto &hist_idx = db.get_index_type<account_transaction_history_index>(); const auto &hist_idx = db.get_index_type<account_transaction_history_index>();
const auto &by_seq_idx = hist_idx.indices().get<by_seq>(); const auto &by_seq_idx = hist_idx.indices().get<by_seq>();
auto itr = by_seq_idx.upper_bound(boost::make_tuple(account, start)); auto itr = by_seq_idx.upper_bound(boost::make_tuple(account, start));
auto itr_stop = by_seq_idx.lower_bound(boost::make_tuple(account, stop)); auto itr_stop = by_seq_idx.lower_bound(boost::make_tuple(account, stop));
do do {
{
--itr; --itr;
result.push_back(itr->operation_id(db)); result.push_back(itr->operation_id(db));
} } while (itr != itr_stop && result.size() < limit);
while ( itr != itr_stop && result.size() < limit );
} }
return result; return result;
} }
vector<account_balance_object> history_api::list_core_accounts()const vector<account_balance_object> history_api::list_core_accounts() const {
{
auto list = _app.get_plugin<accounts_list_plugin>("accounts_list"); auto list = _app.get_plugin<accounts_list_plugin>("accounts_list");
FC_ASSERT(list); FC_ASSERT(list);
return list->list_accounts(); return list->list_accounts();
} }
flat_set<uint32_t> history_api::get_market_history_buckets()const flat_set<uint32_t> history_api::get_market_history_buckets() const {
{
auto hist = _app.get_plugin<market_history_plugin>("market_history"); auto hist = _app.get_plugin<market_history_plugin>("market_history");
FC_ASSERT(hist); FC_ASSERT(hist);
return hist->tracked_buckets(); return hist->tracked_buckets();
} }
vector<bucket_object> history_api::get_market_history(std::string asset_a, std::string asset_b, vector<bucket_object> history_api::get_market_history(std::string asset_a, std::string asset_b,
uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end )const uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end) const {
{ try { try {
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
asset_id_type a = database_api.get_asset_id_from_string(asset_a); asset_id_type a = database_api.get_asset_id_from_string(asset_a);
@ -731,43 +494,40 @@ namespace graphene { namespace app {
vector<bucket_object> result; vector<bucket_object> result;
result.reserve(200); result.reserve(200);
if( a > b ) std::swap(a,b); if (a > b)
std::swap(a, b);
const auto &bidx = db.get_index_type<bucket_index>(); const auto &bidx = db.get_index_type<bucket_index>();
const auto &by_key_idx = bidx.indices().get<by_key>(); const auto &by_key_idx = bidx.indices().get<by_key>();
auto itr = by_key_idx.lower_bound(bucket_key(a, b, bucket_seconds, start)); auto itr = by_key_idx.lower_bound(bucket_key(a, b, bucket_seconds, start));
while( itr != by_key_idx.end() && itr->key.open <= end && result.size() < 200 ) while (itr != by_key_idx.end() && itr->key.open <= end && result.size() < 200) {
{ if (!(itr->key.base == a && itr->key.quote == b && itr->key.seconds == bucket_seconds)) {
if( !(itr->key.base == a && itr->key.quote == b && itr->key.seconds == bucket_seconds) )
{
return result; return result;
} }
result.push_back(*itr); result.push_back(*itr);
++itr; ++itr;
} }
return result; return result;
} FC_CAPTURE_AND_RETHROW( (asset_a)(asset_b)(bucket_seconds)(start)(end) ) } }
FC_CAPTURE_AND_RETHROW((asset_a)(asset_b)(bucket_seconds)(start)(end))
}
crypto_api::crypto_api(){}; crypto_api::crypto_api(){};
commitment_type crypto_api::blind( const blind_factor_type& blind, uint64_t value ) commitment_type crypto_api::blind(const blind_factor_type &blind, uint64_t value) {
{
return fc::ecc::blind(blind, value); return fc::ecc::blind(blind, value);
} }
blind_factor_type crypto_api::blind_sum( const std::vector<blind_factor_type>& blinds_in, uint32_t non_neg ) blind_factor_type crypto_api::blind_sum(const std::vector<blind_factor_type> &blinds_in, uint32_t non_neg) {
{
return fc::ecc::blind_sum(blinds_in, non_neg); return fc::ecc::blind_sum(blinds_in, non_neg);
} }
bool crypto_api::verify_sum( const std::vector<commitment_type>& commits_in, const std::vector<commitment_type>& neg_commits_in, int64_t excess ) bool crypto_api::verify_sum(const std::vector<commitment_type> &commits_in, const std::vector<commitment_type> &neg_commits_in, int64_t excess) {
{
return fc::ecc::verify_sum(commits_in, neg_commits_in, excess); return fc::ecc::verify_sum(commits_in, neg_commits_in, excess);
} }
verify_range_result crypto_api::verify_range( const commitment_type& commit, const std::vector<char>& proof ) verify_range_result crypto_api::verify_range(const commitment_type &commit, const std::vector<char> &proof) {
{
verify_range_result result; verify_range_result result;
result.success = fc::ecc::verify_range(result.min_val, result.max_val, commit, proof); result.success = fc::ecc::verify_range(result.min_val, result.max_val, commit, proof);
return result; return result;
@ -779,15 +539,13 @@ namespace graphene { namespace app {
const blind_factor_type &nonce, const blind_factor_type &nonce,
int8_t base10_exp, int8_t base10_exp,
uint8_t min_bits, uint8_t min_bits,
uint64_t actual_value ) uint64_t actual_value) {
{
return fc::ecc::range_proof_sign(min_value, commit, commit_blind, nonce, base10_exp, min_bits, actual_value); return fc::ecc::range_proof_sign(min_value, commit, commit_blind, nonce, base10_exp, min_bits, actual_value);
} }
verify_range_proof_rewind_result crypto_api::verify_range_proof_rewind(const blind_factor_type &nonce, verify_range_proof_rewind_result crypto_api::verify_range_proof_rewind(const blind_factor_type &nonce,
const commitment_type &commit, const commitment_type &commit,
const std::vector<char>& proof ) const std::vector<char> &proof) {
{
verify_range_proof_rewind_result result; verify_range_proof_rewind_result result;
result.success = fc::ecc::verify_range_proof_rewind(result.blind_out, result.success = fc::ecc::verify_range_proof_rewind(result.blind_out,
result.value_out, result.value_out,
@ -800,8 +558,7 @@ namespace graphene { namespace app {
return result; return result;
} }
range_proof_info crypto_api::range_get_info( const std::vector<char>& proof ) range_proof_info crypto_api::range_get_info(const std::vector<char> &proof) {
{
return fc::ecc::range_get_info(proof); return fc::ecc::range_get_info(proof);
} }
@ -809,8 +566,11 @@ namespace graphene { namespace app {
asset_api::asset_api(graphene::app::application &app) : asset_api::asset_api(graphene::app::application &app) :
_app(app), _app(app),
_db(*app.chain_database()), _db(*app.chain_database()),
database_api( std::ref(*app.chain_database())) { } database_api(std::ref(*app.chain_database())) {
asset_api::~asset_api() { } }
asset_api::~asset_api() {
}
vector<account_asset_balance> asset_api::get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const { vector<account_asset_balance> asset_api::get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const {
FC_ASSERT(limit <= api_limit_get_asset_holders, FC_ASSERT(limit <= api_limit_get_asset_holders,
@ -824,8 +584,7 @@ namespace graphene { namespace app {
vector<account_asset_balance> result; vector<account_asset_balance> result;
uint32_t index = 0; uint32_t index = 0;
for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) ) for (const account_balance_object &bal : boost::make_iterator_range(range.first, range.second)) {
{
if (result.size() >= limit) if (result.size() >= limit)
break; break;
@ -863,8 +622,7 @@ namespace graphene { namespace app {
vector<asset_holders> result; vector<asset_holders> result;
vector<asset_id_type> total_assets; vector<asset_id_type> total_assets;
for( const asset_object& asset_obj : _db.get_index_type<asset_index>().indices() ) for (const asset_object &asset_obj : _db.get_index_type<asset_index>().indices()) {
{
const auto &dasset_obj = asset_obj.dynamic_asset_data_id(_db); const auto &dasset_obj = asset_obj.dynamic_asset_data_id(_db);
asset_id_type asset_id; asset_id_type asset_id;
@ -885,4 +643,4 @@ namespace graphene { namespace app {
return result; return result;
} }
} } // graphene::app }} // namespace graphene::app

File diff suppressed because it is too large Load diff

View file

@ -25,34 +25,34 @@
#include <graphene/app/config_util.hpp> #include <graphene/app/config_util.hpp>
#include <graphene/chain/config.hpp> #include <graphene/chain/config.hpp>
#include <fc/reflect/variant.hpp>
#include <fc/string.hpp>
#include <fc/exception/exception.hpp> #include <fc/exception/exception.hpp>
#include <fc/log/console_appender.hpp> #include <fc/log/console_appender.hpp>
#include <fc/log/file_appender.hpp> #include <fc/log/file_appender.hpp>
#include <fc/log/logger_config.hpp> #include <fc/log/logger_config.hpp>
#include <fc/reflect/variant.hpp>
#include <fc/string.hpp>
#include <boost/property_tree/ptree.hpp> #include <boost/algorithm/string.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/property_tree/ini_parser.hpp>
#include <boost/algorithm/string.hpp> #include <boost/property_tree/ptree.hpp>
#include <fstream> #include <fstream>
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
class deduplicator class deduplicator {
{
public: public:
deduplicator() : modifier(nullptr) {} deduplicator() :
modifier(nullptr) {
}
deduplicator(const boost::shared_ptr<bpo::option_description> (*mod_fn)(const boost::shared_ptr<bpo::option_description>&)) deduplicator(const boost::shared_ptr<bpo::option_description> (*mod_fn)(const boost::shared_ptr<bpo::option_description> &)) :
: modifier(mod_fn) {} modifier(mod_fn) {
}
const boost::shared_ptr<bpo::option_description> next(const boost::shared_ptr<bpo::option_description>& o) const boost::shared_ptr<bpo::option_description> next(const boost::shared_ptr<bpo::option_description> &o) {
{
const std::string name = o->long_name(); const std::string name = o->long_name();
if (seen.find(name) != seen.end()) if (seen.find(name) != seen.end())
return nullptr; return nullptr;
@ -69,8 +69,7 @@ private:
// are all most users would want to change. At a later time, options can // are all most users would want to change. At a later time, options can
// be added to control rotation intervals, compression, and other seldom- // be added to control rotation intervals, compression, and other seldom-
// used features // used features
static void write_default_logging_config_to_stream(std::ostream& out) static void write_default_logging_config_to_stream(std::ostream &out) {
{
out << "# declare an appender named \"stderr\" that writes messages to the console\n" out << "# declare an appender named \"stderr\" that writes messages to the console\n"
"[log.console_appender.stderr]\n" "[log.console_appender.stderr]\n"
"stream=std_error\n\n" "stream=std_error\n\n"
@ -115,17 +114,14 @@ static void write_default_logging_config_to_stream(std::ostream& out)
// logging config is too complicated to be parsed by boost::program_options, // logging config is too complicated to be parsed by boost::program_options,
// so we do it by hand // so we do it by hand
static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const fc::path& config_ini_filename) static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const fc::path &config_ini_filename) {
{ try {
try
{
fc::logging_config logging_config; fc::logging_config logging_config;
bool found_logging_config = false; bool found_logging_config = false;
boost::property_tree::ptree config_ini_tree; boost::property_tree::ptree config_ini_tree;
boost::property_tree::ini_parser::read_ini(config_ini_filename.preferred_string().c_str(), config_ini_tree); boost::property_tree::ini_parser::read_ini(config_ini_filename.preferred_string().c_str(), config_ini_tree);
for (const auto& section : config_ini_tree) for (const auto &section : config_ini_tree) {
{
const std::string &section_name = section.first; const std::string &section_name = section.first;
const boost::property_tree::ptree &section_tree = section.second; const boost::property_tree::ptree &section_tree = section.second;
@ -133,8 +129,7 @@ static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const
const std::string file_appender_section_prefix = "log.file_appender."; const std::string file_appender_section_prefix = "log.file_appender.";
const std::string logger_section_prefix = "logger."; const std::string logger_section_prefix = "logger.";
if (boost::starts_with(section_name, console_appender_section_prefix)) if (boost::starts_with(section_name, console_appender_section_prefix)) {
{
std::string console_appender_name = section_name.substr(console_appender_section_prefix.length()); std::string console_appender_name = section_name.substr(console_appender_section_prefix.length());
std::string stream_name = section_tree.get<std::string>("stream"); std::string stream_name = section_tree.get<std::string>("stream");
@ -153,9 +148,7 @@ static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const
console_appender_config.stream = fc::variant(stream_name).as<fc::console_appender::stream::type>(GRAPHENE_MAX_NESTED_OBJECTS); console_appender_config.stream = fc::variant(stream_name).as<fc::console_appender::stream::type>(GRAPHENE_MAX_NESTED_OBJECTS);
logging_config.appenders.push_back(fc::appender_config(console_appender_name, "console", fc::variant(console_appender_config, GRAPHENE_MAX_NESTED_OBJECTS))); logging_config.appenders.push_back(fc::appender_config(console_appender_name, "console", fc::variant(console_appender_config, GRAPHENE_MAX_NESTED_OBJECTS)));
found_logging_config = true; found_logging_config = true;
} } else if (boost::starts_with(section_name, file_appender_section_prefix)) {
else if (boost::starts_with(section_name, file_appender_section_prefix))
{
std::string file_appender_name = section_name.substr(file_appender_section_prefix.length()); std::string file_appender_name = section_name.substr(file_appender_section_prefix.length());
fc::path file_name = section_tree.get<std::string>("filename"); fc::path file_name = section_tree.get<std::string>("filename");
if (file_name.is_relative()) if (file_name.is_relative())
@ -174,9 +167,7 @@ static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const
file_appender_config.rotation_limit = fc::days(limit); file_appender_config.rotation_limit = fc::days(limit);
logging_config.appenders.push_back(fc::appender_config(file_appender_name, "file", fc::variant(file_appender_config, GRAPHENE_MAX_NESTED_OBJECTS))); logging_config.appenders.push_back(fc::appender_config(file_appender_name, "file", fc::variant(file_appender_config, GRAPHENE_MAX_NESTED_OBJECTS)));
found_logging_config = true; found_logging_config = true;
} } else if (boost::starts_with(section_name, logger_section_prefix)) {
else if (boost::starts_with(section_name, logger_section_prefix))
{
std::string logger_name = section_name.substr(logger_section_prefix.length()); std::string logger_name = section_name.substr(logger_section_prefix.length());
std::string level_string = section_tree.get<std::string>("level"); std::string level_string = section_tree.get<std::string>("level");
std::string appenders_string = section_tree.get<std::string>("appenders"); std::string appenders_string = section_tree.get<std::string>("appenders");
@ -197,53 +188,45 @@ static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const
FC_RETHROW_EXCEPTIONS(warn, "") FC_RETHROW_EXCEPTIONS(warn, "")
} }
static const boost::shared_ptr<bpo::option_description> new_option_description( const std::string& name, const bpo::value_semantic* value, const std::string& description ) static const boost::shared_ptr<bpo::option_description> new_option_description(const std::string &name, const bpo::value_semantic *value, const std::string &description) {
{
bpo::options_description helper(""); bpo::options_description helper("");
helper.add_options()(name.c_str(), value, description.c_str()); helper.add_options()(name.c_str(), value, description.c_str());
return helper.options()[0]; return helper.options()[0];
} }
static void load_config_file(const fc::path &config_ini_path, const bpo::options_description &cfg_options, static void load_config_file(const fc::path &config_ini_path, const bpo::options_description &cfg_options,
bpo::variables_map& options ) bpo::variables_map &options) {
{
deduplicator dedup; deduplicator dedup;
bpo::options_description unique_options("Graphene Witness Node"); bpo::options_description unique_options("Graphene Witness Node");
for( const boost::shared_ptr<bpo::option_description> opt : cfg_options.options() ) for (const boost::shared_ptr<bpo::option_description> opt : cfg_options.options()) {
{
const boost::shared_ptr<bpo::option_description> od = dedup.next(opt); const boost::shared_ptr<bpo::option_description> od = dedup.next(opt);
if( !od ) continue; if (!od)
continue;
unique_options.add(od); unique_options.add(od);
} }
// get the basic options // get the basic options
bpo::store(bpo::parse_config_file<char>(config_ini_path.preferred_string().c_str(), bpo::store(bpo::parse_config_file<char>(config_ini_path.preferred_string().c_str(),
unique_options, true), options); unique_options, true),
options);
} }
static bool load_logging_config_file(const fc::path& config_ini_path) static bool load_logging_config_file(const fc::path &config_ini_path) {
{
// try to get logging options from the config file. // try to get logging options from the config file.
try try {
{
fc::optional<fc::logging_config> logging_config = load_logging_config_from_ini_file(config_ini_path); fc::optional<fc::logging_config> logging_config = load_logging_config_from_ini_file(config_ini_path);
if (logging_config) if (logging_config) {
{
fc::configure_logging(*logging_config); fc::configure_logging(*logging_config);
return true; return true;
} }
} } catch (const fc::exception &ex) {
catch (const fc::exception& ex)
{
wlog("Error parsing logging config from logging config file ${config}, using default config", ("config", config_ini_path.preferred_string())); wlog("Error parsing logging config from logging config file ${config}, using default config", ("config", config_ini_path.preferred_string()));
} }
return false; return false;
} }
static void create_new_config_file(const fc::path &config_ini_path, const fc::path &data_dir, static void create_new_config_file(const fc::path &config_ini_path, const fc::path &data_dir,
const bpo::options_description& cfg_options ) const bpo::options_description &cfg_options) {
{
ilog("Writing new config file at ${path}", ("path", config_ini_path)); ilog("Writing new config file at ${path}", ("path", config_ini_path));
if (!fc::exists(data_dir)) if (!fc::exists(data_dir))
fc::create_directories(data_dir); fc::create_directories(data_dir);
@ -259,10 +242,10 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
deduplicator dedup(modify_option_defaults); deduplicator dedup(modify_option_defaults);
std::ofstream out_cfg(config_ini_path.preferred_string()); std::ofstream out_cfg(config_ini_path.preferred_string());
std::string plugin_header_surrounding(78, '='); std::string plugin_header_surrounding(78, '=');
for( const boost::shared_ptr<bpo::option_description> opt : cfg_options.options() ) for (const boost::shared_ptr<bpo::option_description> opt : cfg_options.options()) {
{
const boost::shared_ptr<bpo::option_description> od = dedup.next(opt); const boost::shared_ptr<bpo::option_description> od = dedup.next(opt);
if( !od ) continue; if (!od)
continue;
if (od->long_name().find("plugin-cfg-header-") == 0) // it's a plugin header if (od->long_name().find("plugin-cfg-header-") == 0) // it's a plugin header
{ {
@ -283,7 +266,8 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
auto example = od->format_parameter(); auto example = od->format_parameter();
if (example.empty()) if (example.empty())
// This is a boolean switch // This is a boolean switch
out_cfg << od->long_name() << " = " << "false\n"; out_cfg << od->long_name() << " = "
<< "false\n";
else { else {
// The string is formatted "arg (=<interesting part>)" // The string is formatted "arg (=<interesting part>)"
example.erase(0, 6); example.erase(0, 6);
@ -304,11 +288,9 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
out_cfg.close(); out_cfg.close();
} }
static void create_logging_config_file(const fc::path& config_ini_path, const fc::path& data_dir) static void create_logging_config_file(const fc::path &config_ini_path, const fc::path &data_dir) {
{
ilog("Writing new config file at ${path}", ("path", config_ini_path)); ilog("Writing new config file at ${path}", ("path", config_ini_path));
if (!exists(data_dir)) if (!exists(data_dir)) {
{
create_directories(data_dir); create_directories(data_dir);
} }
@ -319,18 +301,14 @@ static void create_logging_config_file(const fc::path& config_ini_path, const fc
namespace graphene { namespace app { namespace graphene { namespace app {
void load_configuration_options(const fc::path& data_dir, const bpo::options_description& cfg_options, bpo::variables_map& options) void load_configuration_options(const fc::path &data_dir, const bpo::options_description &cfg_options, bpo::variables_map &options) {
{
const auto config_ini_path = data_dir / "config.ini"; const auto config_ini_path = data_dir / "config.ini";
const auto logging_ini_path = data_dir / "logging.ini"; const auto logging_ini_path = data_dir / "logging.ini";
if(!exists(config_ini_path) && fc::exists(logging_ini_path)) if (!exists(config_ini_path) && fc::exists(logging_ini_path)) {
{
// this is an uncommon case // this is an uncommon case
create_new_config_file(config_ini_path, data_dir, cfg_options); create_new_config_file(config_ini_path, data_dir, cfg_options);
} } else if (!exists(config_ini_path)) {
else if(!exists(config_ini_path))
{
// create default config.ini and logging.ini // create default config.ini and logging.ini
create_new_config_file(config_ini_path, data_dir, cfg_options); create_new_config_file(config_ini_path, data_dir, cfg_options);
create_logging_config_file(logging_ini_path, data_dir); create_logging_config_file(logging_ini_path, data_dir);
@ -340,15 +318,12 @@ namespace graphene { namespace app {
load_config_file(config_ini_path, cfg_options, options); load_config_file(config_ini_path, cfg_options, options);
// load logging configuration // load logging configuration
if (fc::exists(logging_ini_path)) if (fc::exists(logging_ini_path)) {
{
load_logging_config_file(logging_ini_path); load_logging_config_file(logging_ini_path);
} } else {
else
{
// this is the legacy config.ini case // this is the legacy config.ini case
load_logging_config_file(config_ini_path); load_logging_config_file(config_ini_path);
} }
} }
} } // graphene::app }} // namespace graphene::app

File diff suppressed because it is too large Load diff

View file

@ -25,24 +25,24 @@
#include <graphene/app/database_api.hpp> #include <graphene/app/database_api.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/confidential.hpp> #include <graphene/chain/protocol/confidential.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
#include <graphene/accounts_list/accounts_list_plugin.hpp> #include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
#include <graphene/elasticsearch/elasticsearch_plugin.hpp> #include <graphene/elasticsearch/elasticsearch_plugin.hpp>
#include <graphene/debug_witness/debug_api.hpp>
#include <graphene/affiliate_stats/affiliate_stats_api.hpp> #include <graphene/affiliate_stats/affiliate_stats_api.hpp>
#include <graphene/bookie/bookie_api.hpp> #include <graphene/bookie/bookie_api.hpp>
#include <graphene/debug_witness/debug_api.hpp>
#include <graphene/net/node.hpp> #include <graphene/net/node.hpp>
#include <fc/api.hpp> #include <fc/api.hpp>
#include <fc/optional.hpp>
#include <fc/crypto/elliptic.hpp> #include <fc/crypto/elliptic.hpp>
#include <fc/network/ip.hpp> #include <fc/network/ip.hpp>
#include <fc/optional.hpp>
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
@ -60,15 +60,13 @@ namespace graphene { namespace app {
class application; class application;
struct verify_range_result struct verify_range_result {
{
bool success; bool success;
uint64_t min_val; uint64_t min_val;
uint64_t max_val; uint64_t max_val;
}; };
struct verify_range_proof_rewind_result struct verify_range_proof_rewind_result {
{
bool success; bool success;
uint64_t min_val; uint64_t min_val;
uint64_t max_val; uint64_t max_val;
@ -77,14 +75,12 @@ namespace graphene { namespace app {
string message_out; string message_out;
}; };
struct account_asset_balance struct account_asset_balance {
{
string name; string name;
account_id_type account_id; account_id_type account_id;
share_type amount; share_type amount;
}; };
struct asset_holders struct asset_holders {
{
asset_id_type asset_id; asset_id_type asset_id;
int count; int count;
}; };
@ -94,11 +90,12 @@ namespace graphene { namespace app {
* *
* This API contains methods to access account histories * This API contains methods to access account histories
*/ */
class history_api class history_api {
{
public: public:
history_api(application& app) history_api(application &app) :
:_app(app), database_api( std::ref(*app.chain_database())) {} _app(app),
database_api(std::ref(*app.chain_database())) {
}
/** /**
* @brief Get operations relevant to the specificed account * @brief Get operations relevant to the specificed account
@ -153,6 +150,7 @@ namespace graphene { namespace app {
uint32_t api_limit_get_account_history_operations = 100; uint32_t api_limit_get_account_history_operations = 100;
uint32_t api_limit_get_account_history = 100; uint32_t api_limit_get_account_history = 100;
uint32_t api_limit_get_relative_account_history = 100; uint32_t api_limit_get_relative_account_history = 100;
private: private:
application &_app; application &_app;
graphene::app::database_api database_api; graphene::app::database_api database_api;
@ -161,8 +159,7 @@ namespace graphene { namespace app {
/** /**
* @brief Block api * @brief Block api
*/ */
class block_api class block_api {
{
public: public:
block_api(graphene::chain::database &db); block_api(graphene::chain::database &db);
~block_api(); ~block_api();
@ -173,17 +170,14 @@ namespace graphene { namespace app {
graphene::chain::database &_db; graphene::chain::database &_db;
}; };
/** /**
* @brief The network_broadcast_api class allows broadcasting of transactions. * @brief The network_broadcast_api class allows broadcasting of transactions.
*/ */
class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api> class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api> {
{
public: public:
network_broadcast_api(application &a); network_broadcast_api(application &a);
struct transaction_confirmation struct transaction_confirmation {
{
transaction_id_type id; transaction_id_type id;
uint32_t block_num; uint32_t block_num;
uint32_t trx_num; uint32_t trx_num;
@ -224,6 +218,7 @@ namespace graphene { namespace app {
* to be notified when a particular txid is included in a block. * to be notified when a particular txid is included in a block.
*/ */
void on_applied_block(const signed_block &b); void on_applied_block(const signed_block &b);
private: private:
boost::signals2::scoped_connection _applied_block_connection; boost::signals2::scoped_connection _applied_block_connection;
map<transaction_id_type, confirmation_callback> _callbacks; map<transaction_id_type, confirmation_callback> _callbacks;
@ -233,8 +228,7 @@ namespace graphene { namespace app {
/** /**
* @brief The network_node_api class allows maintenance of p2p connections. * @brief The network_node_api class allows maintenance of p2p connections.
*/ */
class network_node_api class network_node_api {
{
public: public:
network_node_api(application &a); network_node_api(application &a);
@ -296,8 +290,7 @@ namespace graphene { namespace app {
std::function<void(const variant &)> _on_pending_transaction; std::function<void(const variant &)> _on_pending_transaction;
}; };
class crypto_api class crypto_api {
{
public: public:
crypto_api(); crypto_api();
@ -317,20 +310,17 @@ namespace graphene { namespace app {
uint8_t min_bits, uint8_t min_bits,
uint64_t actual_value); uint64_t actual_value);
verify_range_proof_rewind_result verify_range_proof_rewind(const blind_factor_type &nonce, verify_range_proof_rewind_result verify_range_proof_rewind(const blind_factor_type &nonce,
const fc::ecc::commitment_type &commit, const fc::ecc::commitment_type &commit,
const std::vector<char> &proof); const std::vector<char> &proof);
range_proof_info range_get_info(const std::vector<char> &proof); range_proof_info range_get_info(const std::vector<char> &proof);
}; };
/** /**
* @brief * @brief
*/ */
class asset_api class asset_api {
{
public: public:
asset_api(graphene::app::application &app); asset_api(graphene::app::application &app);
~asset_api(); ~asset_api();
@ -358,12 +348,13 @@ namespace graphene { namespace app {
vector<asset_holders> get_all_asset_holders() const; vector<asset_holders> get_all_asset_holders() const;
uint32_t api_limit_get_asset_holders = 100; uint32_t api_limit_get_asset_holders = 100;
private: private:
graphene::app::application &_app; graphene::app::application &_app;
graphene::chain::database &_db; graphene::chain::database &_db;
graphene::app::database_api database_api; graphene::app::database_api database_api;
}; };
} } // graphene::app }} // namespace graphene::app
extern template class fc::api<graphene::app::block_api>; extern template class fc::api<graphene::app::block_api>;
extern template class fc::api<graphene::app::network_broadcast_api>; extern template class fc::api<graphene::app::network_broadcast_api>;
@ -379,8 +370,7 @@ namespace graphene { namespace app {
* *
* All other APIs must be requested from this API. * All other APIs must be requested from this API.
*/ */
class login_api class login_api {
{
public: public:
login_api(application &a); login_api(application &a);
~login_api(); ~login_api();
@ -418,8 +408,8 @@ namespace graphene { namespace app {
/// @brief Called to enable an API, not reflected. /// @brief Called to enable an API, not reflected.
void enable_api(const string &api_name); void enable_api(const string &api_name);
private:
private:
application &_app; application &_app;
optional<fc::api<block_api>> _block_api; optional<fc::api<block_api>> _block_api;
optional<fc::api<database_api>> _database_api; optional<fc::api<database_api>> _database_api;
@ -433,21 +423,26 @@ namespace graphene { namespace app {
optional<fc::api<graphene::affiliate_stats::affiliate_stats_api>> _affiliate_stats_api; optional<fc::api<graphene::affiliate_stats::affiliate_stats_api>> _affiliate_stats_api;
}; };
}} // graphene::app }} // namespace graphene::app
extern template class fc::api<graphene::app::login_api>; extern template class fc::api<graphene::app::login_api>;
// clang-format off
FC_REFLECT(graphene::app::network_broadcast_api::transaction_confirmation, FC_REFLECT(graphene::app::network_broadcast_api::transaction_confirmation,
(id)(block_num)(trx_num)(trx)) (id)(block_num)(trx_num)(trx))
FC_REFLECT(graphene::app::verify_range_result, FC_REFLECT(graphene::app::verify_range_result,
(success)(min_val)(max_val)) (success)(min_val)(max_val))
FC_REFLECT(graphene::app::verify_range_proof_rewind_result, FC_REFLECT(graphene::app::verify_range_proof_rewind_result,
(success)(min_val)(max_val)(value_out)(blind_out)(message_out)) (success)(min_val)(max_val)(value_out)(blind_out)(message_out))
//FC_REFLECT_TYPENAME( fc::ecc::compact_signature );
//FC_REFLECT_TYPENAME( fc::ecc::commitment_type );
FC_REFLECT( graphene::app::account_asset_balance, (name)(account_id)(amount) ); FC_REFLECT(graphene::app::account_asset_balance,
FC_REFLECT( graphene::app::asset_holders, (asset_id)(count) ); (name)(account_id)(amount));
FC_REFLECT(graphene::app::asset_holders,
(asset_id)(count));
FC_API(graphene::app::history_api, FC_API(graphene::app::history_api,
(get_account_history) (get_account_history)
@ -456,17 +451,17 @@ FC_API(graphene::app::history_api,
(get_fill_order_history) (get_fill_order_history)
(get_market_history) (get_market_history)
(get_market_history_buckets) (get_market_history_buckets)
(list_core_accounts) (list_core_accounts))
)
FC_API(graphene::app::block_api, FC_API(graphene::app::block_api,
(get_blocks) (get_blocks))
)
FC_API(graphene::app::network_broadcast_api, FC_API(graphene::app::network_broadcast_api,
(broadcast_transaction) (broadcast_transaction)
(broadcast_transaction_with_callback) (broadcast_transaction_with_callback)
(broadcast_transaction_synchronous) (broadcast_transaction_synchronous)
(broadcast_block) (broadcast_block))
)
FC_API(graphene::app::network_node_api, FC_API(graphene::app::network_node_api,
(get_info) (get_info)
(add_node) (add_node)
@ -476,8 +471,8 @@ FC_API(graphene::app::network_node_api,
(set_advanced_node_parameters) (set_advanced_node_parameters)
(list_pending_transactions) (list_pending_transactions)
(subscribe_to_pending_transactions) (subscribe_to_pending_transactions)
(unsubscribe_from_pending_transactions) (unsubscribe_from_pending_transactions))
)
FC_API(graphene::app::crypto_api, FC_API(graphene::app::crypto_api,
(blind) (blind)
(blind_sum) (blind_sum)
@ -485,13 +480,13 @@ FC_API(graphene::app::crypto_api,
(verify_range) (verify_range)
(range_proof_sign) (range_proof_sign)
(verify_range_proof_rewind) (verify_range_proof_rewind)
(range_get_info) (range_get_info))
)
FC_API(graphene::app::asset_api, FC_API(graphene::app::asset_api,
(get_asset_holders) (get_asset_holders)
(get_asset_holders_count) (get_asset_holders_count)
(get_all_asset_holders) (get_all_asset_holders))
)
FC_API(graphene::app::login_api, FC_API(graphene::app::login_api,
(login) (login)
(block) (block)
@ -503,5 +498,6 @@ FC_API(graphene::app::login_api,
(asset) (asset)
(debug) (debug)
(bookie) (bookie)
(affiliate_stats) (affiliate_stats))
)
// clang-format on

View file

@ -31,26 +31,26 @@
namespace graphene { namespace app { namespace graphene { namespace app {
struct api_access_info struct api_access_info {
{
std::string password_hash_b64; std::string password_hash_b64;
std::string password_salt_b64; std::string password_salt_b64;
std::vector<std::string> allowed_apis; std::vector<std::string> allowed_apis;
}; };
struct api_access struct api_access {
{
std::map<std::string, api_access_info> permission_map; std::map<std::string, api_access_info> permission_map;
}; };
} } // graphene::app }} // namespace graphene::app
// clang-format off
FC_REFLECT( graphene::app::api_access_info, FC_REFLECT( graphene::app::api_access_info,
(password_hash_b64) (password_hash_b64)
(password_salt_b64) (password_salt_b64)
(allowed_apis) (allowed_apis))
)
FC_REFLECT( graphene::app::api_access, FC_REFLECT( graphene::app::api_access,
(permission_map) (permission_map))
)
// clang-format on

View file

@ -24,25 +24,26 @@
#pragma once #pragma once
#include <graphene/app/api_access.hpp> #include <graphene/app/api_access.hpp>
#include <graphene/net/node.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/net/node.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
namespace graphene { namespace app { namespace graphene { namespace app {
namespace detail { class application_impl; } namespace detail {
class application_impl;
}
using std::string; using std::string;
class abstract_plugin; class abstract_plugin;
class application class application {
{
public: public:
application(); application();
~application(); ~application();
void set_program_options( boost::program_options::options_description& command_line_options, void set_program_options(boost::program_options::options_description &cli,
boost::program_options::options_description& configuration_file_options )const; boost::program_options::options_description &cfg) const;
void initialize(const fc::path &data_dir, const boost::program_options::variables_map &options); void initialize(const fc::path &data_dir, const boost::program_options::variables_map &options);
void initialize_plugins(const boost::program_options::variables_map &options); void initialize_plugins(const boost::program_options::variables_map &options);
void startup(); void startup();
@ -51,19 +52,16 @@ namespace graphene { namespace app {
void shutdown_plugins(); void shutdown_plugins();
template <typename PluginType> template <typename PluginType>
std::shared_ptr<PluginType> register_plugin() std::shared_ptr<PluginType> register_plugin() {
{
auto plug = std::make_shared<PluginType>(); auto plug = std::make_shared<PluginType>();
plug->plugin_set_app(this); plug->plugin_set_app(this);
boost::program_options::options_description plugin_cli_options(plug->plugin_name() + " plugin. " + plug->plugin_description() + "\nOptions"), plugin_cfg_options; boost::program_options::options_description plugin_cli_options(plug->plugin_name() + " plugin. " + plug->plugin_description() + "\nOptions"), plugin_cfg_options;
//boost::program_options::options_description plugin_cli_options("Options for plugin " + plug->plugin_name()), plugin_cfg_options;
plug->plugin_set_program_options(plugin_cli_options, plugin_cfg_options); plug->plugin_set_program_options(plugin_cli_options, plugin_cfg_options);
if (!plugin_cli_options.options().empty()) if (!plugin_cli_options.options().empty())
_cli_options.add(plugin_cli_options); _cli_options.add(plugin_cli_options);
if( !plugin_cfg_options.options().empty() ) if (!plugin_cfg_options.options().empty()) {
{
std::string header_name = "plugin-cfg-header-" + plug->plugin_name(); std::string header_name = "plugin-cfg-header-" + plug->plugin_name();
std::string header_desc = plug->plugin_name() + " plugin options"; std::string header_desc = plug->plugin_name() + " plugin options";
_cfg_options.add_options()(header_name.c_str(), header_desc.c_str()); _cfg_options.add_options()(header_name.c_str(), header_desc.c_str());
@ -76,8 +74,7 @@ namespace graphene { namespace app {
std::shared_ptr<abstract_plugin> get_plugin(const string &name) const; std::shared_ptr<abstract_plugin> get_plugin(const string &name) const;
template <typename PluginType> template <typename PluginType>
std::shared_ptr<PluginType> get_plugin( const string& name ) const std::shared_ptr<PluginType> get_plugin(const string &name) const {
{
std::shared_ptr<abstract_plugin> abs_plugin = get_plugin(name); std::shared_ptr<abstract_plugin> abs_plugin = get_plugin(name);
std::shared_ptr<PluginType> result = std::dynamic_pointer_cast<PluginType>(abs_plugin); std::shared_ptr<PluginType> result = std::dynamic_pointer_cast<PluginType>(abs_plugin);
FC_ASSERT(result != std::shared_ptr<PluginType>()); FC_ASSERT(result != std::shared_ptr<PluginType>());
@ -109,4 +106,4 @@ namespace graphene { namespace app {
boost::program_options::options_description _cfg_options; boost::program_options::options_description _cfg_options;
}; };
} } }} // namespace graphene::app

View file

@ -23,12 +23,12 @@
*/ */
#pragma once #pragma once
#include <fc/filesystem.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <fc/filesystem.hpp>
namespace graphene { namespace app { namespace graphene { namespace app {
void load_configuration_options(const fc::path &data_dir, const boost::program_options::options_description &cfg_options, void load_configuration_options(const fc::path &data_dir, const boost::program_options::options_description &cfg_options,
boost::program_options::variables_map &options); boost::program_options::variables_map &options);
} } // graphene::app }} // namespace graphene::app

View file

@ -32,30 +32,30 @@
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/balance_object.hpp> #include <graphene/chain/balance_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/chain_property_object.hpp> #include <graphene/chain/chain_property_object.hpp>
#include <graphene/chain/committee_member_object.hpp> #include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/confidential_object.hpp> #include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/global_betting_statistics_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/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/sport_object.hpp> #include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/global_betting_statistics_object.hpp>
#include <graphene/chain/son_object.hpp> #include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_wallet_object.hpp> #include <graphene/chain/son_wallet_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp> #include <graphene/chain/sport_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/tournament_object.hpp> #include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/custom_permission_object.hpp> #include <graphene/chain/account_role_object.hpp>
#include <graphene/chain/custom_account_authority_object.hpp> #include <graphene/chain/custom_account_authority_object.hpp>
#include <graphene/chain/custom_permission_object.hpp>
#include <graphene/chain/nft_object.hpp> #include <graphene/chain/nft_object.hpp>
#include <graphene/chain/offer_object.hpp> #include <graphene/chain/offer_object.hpp>
#include <graphene/chain/account_role_object.hpp>
#include <graphene/market_history/market_history_plugin.hpp> #include <graphene/market_history/market_history_plugin.hpp>
@ -80,23 +80,20 @@ using namespace std;
class database_api_impl; class database_api_impl;
struct order struct order {
{
double price; double price;
double quote; double quote;
double base; double base;
}; };
struct order_book struct order_book {
{
string base; string base;
string quote; string quote;
vector<order> bids; vector<order> bids;
vector<order> asks; vector<order> asks;
}; };
struct market_ticker struct market_ticker {
{
string base; string base;
string quote; string quote;
double latest; double latest;
@ -107,16 +104,14 @@ struct market_ticker
double quote_volume; double quote_volume;
}; };
struct market_volume struct market_volume {
{
string base; string base;
string quote; string quote;
double base_volume; double base_volume;
double quote_volume; double quote_volume;
}; };
struct market_trade struct market_trade {
{
fc::time_point_sec date; fc::time_point_sec date;
double price; double price;
double amount; double amount;
@ -140,8 +135,7 @@ struct gpos_info {
* read-only; all modifications to the database must be performed via transactions. Transactions are broadcast via * read-only; all modifications to the database must be performed via transactions. Transactions are broadcast via
* the @ref network_broadcast_api. * the @ref network_broadcast_api.
*/ */
class database_api class database_api {
{
public: public:
database_api(graphene::chain::database &db); database_api(graphene::chain::database &db);
~database_api(); ~database_api();
@ -191,7 +185,6 @@ class database_api
*/ */
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const; map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const;
/** /**
* @brief Retrieve a full, signed block * @brief Retrieve a full, signed block
* @param block_num Height of the block to be returned * @param block_num Height of the block to be returned
@ -413,7 +406,6 @@ class database_api
*/ */
asset get_lottery_balance(asset_id_type lottery_id) const; asset get_lottery_balance(asset_id_type lottery_id) const;
///////////////////// /////////////////////
// Peerplays // // Peerplays //
///////////////////// /////////////////////
@ -548,8 +540,6 @@ class database_api
*/ */
vector<market_trade> get_trade_history(const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100) const; vector<market_trade> get_trade_history(const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100) const;
/////////////// ///////////////
// Witnesses // // Witnesses //
/////////////// ///////////////
@ -717,7 +707,6 @@ class database_api
*/ */
vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const; vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const;
/////////// ///////////
// Votes // // Votes //
/////////// ///////////
@ -947,10 +936,12 @@ class database_api
std::shared_ptr<database_api_impl> my; std::shared_ptr<database_api_impl> my;
}; };
} } }} // namespace graphene::app
extern template class fc::api<graphene::app::database_api>; extern template class fc::api<graphene::app::database_api>;
// clang-format off
FC_REFLECT(graphene::app::order, (price)(quote)(base)); FC_REFLECT(graphene::app::order, (price)(quote)(base));
FC_REFLECT(graphene::app::order_book, (base)(quote)(bids)(asks)); FC_REFLECT(graphene::app::order_book, (base)(quote)(bids)(asks));
FC_REFLECT(graphene::app::market_ticker, (base)(quote)(latest)(lowest_ask)(highest_bid)(percent_change)(base_volume)(quote_volume)); FC_REFLECT(graphene::app::market_ticker, (base)(quote)(latest)(lowest_ask)(highest_bid)(percent_change)(base_volume)(quote_volume));
@ -958,7 +949,6 @@ FC_REFLECT( graphene::app::market_volume, (base)(quote)(base_volume)(quote_volum
FC_REFLECT(graphene::app::market_trade, (date)(price)(amount)(value)); FC_REFLECT(graphene::app::market_trade, (date)(price)(amount)(value));
FC_REFLECT(graphene::app::gpos_info, (vesting_factor)(award)(total_amount)(current_subperiod)(last_voted_time)(allowed_withdraw_amount)(account_vested_balance)); FC_REFLECT(graphene::app::gpos_info, (vesting_factor)(award)(total_amount)(current_subperiod)(last_voted_time)(allowed_withdraw_amount)(account_vested_balance));
FC_API(graphene::app::database_api, FC_API(graphene::app::database_api,
// Objects // Objects
(get_objects) (get_objects)
@ -1136,3 +1126,5 @@ FC_API(graphene::app::database_api,
// Account Roles // Account Roles
(get_account_roles_by_owner) (get_account_roles_by_owner)
) )
// clang-format on

View file

@ -24,15 +24,14 @@
#pragma once #pragma once
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/market_evaluator.hpp> #include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp> #include <graphene/chain/withdraw_permission_object.hpp>
namespace graphene { namespace app { namespace graphene { namespace app {
using namespace graphene::chain; using namespace graphene::chain;
struct full_account struct full_account {
{
account_object account; account_object account;
account_statistics_object statistics; account_statistics_object statistics;
string registrar_name; string registrar_name;
@ -52,7 +51,9 @@ namespace graphene { namespace app {
vector<pending_dividend_payout_balance_for_holder_object> pending_dividend_payments; vector<pending_dividend_payout_balance_for_holder_object> pending_dividend_payments;
}; };
} } }} // namespace graphene::app
// clang-format off
FC_REFLECT(graphene::app::full_account, FC_REFLECT(graphene::app::full_account,
(account) (account)
@ -70,5 +71,6 @@ FC_REFLECT( graphene::app::full_account,
(proposals) (proposals)
(assets) (assets)
(withdraws) (withdraws)
(pending_dividend_payments) (pending_dividend_payments))
)
// clang-format on

View file

@ -30,10 +30,10 @@
namespace graphene { namespace app { namespace graphene { namespace app {
class abstract_plugin class abstract_plugin {
{
public: public:
virtual ~abstract_plugin(){} virtual ~abstract_plugin() {
}
virtual std::string plugin_name() const = 0; virtual std::string plugin_name() const = 0;
virtual std::string plugin_description() const = 0; virtual std::string plugin_description() const = 0;
@ -84,18 +84,15 @@ class abstract_plugin
* If a plugin does not need these options, it * If a plugin does not need these options, it
* may simply provide an empty implementation of this method. * may simply provide an empty implementation of this method.
*/ */
virtual void plugin_set_program_options( virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options,
boost::program_options::options_description& command_line_options, boost::program_options::options_description &config_file_options) = 0;
boost::program_options::options_description& config_file_options
) = 0;
}; };
/** /**
* Provides basic default implementations of abstract_plugin functions. * Provides basic default implementations of abstract_plugin functions.
*/ */
class plugin : public abstract_plugin class plugin : public abstract_plugin {
{
public: public:
plugin(); plugin();
virtual ~plugin() override; virtual ~plugin() override;
@ -106,15 +103,21 @@ class plugin : public abstract_plugin
virtual void plugin_startup() override; virtual void plugin_startup() override;
virtual void plugin_shutdown() override; virtual void plugin_shutdown() override;
virtual void plugin_set_app(application *app) override; virtual void plugin_set_app(application *app) override;
virtual void plugin_set_program_options( virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options,
boost::program_options::options_description& command_line_options, boost::program_options::options_description &config_file_options) override;
boost::program_options::options_description& config_file_options
) override; chain::database &database() {
return *app().chain_database();
}
application &app() const {
assert(_app);
return *_app;
}
chain::database& database() { return *app().chain_database(); }
application& app()const { assert(_app); return *_app; }
protected: protected:
net::node& p2p_node() { return *app().p2p_node(); } net::node &p2p_node() {
return *app().p2p_node();
}
private: private:
application *_app = nullptr; application *_app = nullptr;
@ -123,18 +126,16 @@ class plugin : public abstract_plugin
/// @group Some useful tools for boost::program_options arguments using vectors of JSON strings /// @group Some useful tools for boost::program_options arguments using vectors of JSON strings
/// @{ /// @{
template <typename T> template <typename T>
T dejsonify(const string& s, uint32_t max_depth) T dejsonify(const string &s, uint32_t max_depth) {
{
return fc::json::from_string(s).as<T>(max_depth); return fc::json::from_string(s).as<T>(max_depth);
} }
namespace impl { namespace impl {
template <typename T> template <typename T>
T dejsonify( const string& s ) T dejsonify(const string &s) {
{
return graphene::app::dejsonify<T>(s, GRAPHENE_MAX_NESTED_OBJECTS); return graphene::app::dejsonify<T>(s, GRAPHENE_MAX_NESTED_OBJECTS);
} }
} } // namespace impl
#define DEFAULT_VALUE_VECTOR(value) default_value({fc::json::to_string(value)}, fc::json::to_string(value)) #define DEFAULT_VALUE_VECTOR(value) default_value({fc::json::to_string(value)}, fc::json::to_string(value))
#define LOAD_VALUE_SET(options, name, container, type) \ #define LOAD_VALUE_SET(options, name, container, type) \
@ -144,4 +145,4 @@ if( options.count(name) ) { \
} }
/// @} /// @}
} } //graphene::app }} // namespace graphene::app

View file

@ -27,54 +27,44 @@
namespace graphene { namespace app { namespace graphene { namespace app {
plugin::plugin() plugin::plugin() {
{
_app = nullptr; _app = nullptr;
return; return;
} }
plugin::~plugin() plugin::~plugin() {
{
return; return;
} }
std::string plugin::plugin_name()const std::string plugin::plugin_name() const {
{
return "<unknown plugin>"; return "<unknown plugin>";
} }
std::string plugin::plugin_description()const std::string plugin::plugin_description() const {
{
return "<no description>"; return "<no description>";
} }
void plugin::plugin_initialize( const boost::program_options::variables_map& options ) void plugin::plugin_initialize(const boost::program_options::variables_map &options) {
{
return; return;
} }
void plugin::plugin_startup() void plugin::plugin_startup() {
{
return; return;
} }
void plugin::plugin_shutdown() void plugin::plugin_shutdown() {
{
return; return;
} }
void plugin::plugin_set_app( application* app ) void plugin::plugin_set_app(application *app) {
{
_app = app; _app = app;
return; return;
} }
void plugin::plugin_set_program_options( void plugin::plugin_set_program_options(
boost::program_options::options_description& command_line_options, boost::program_options::options_description &cli,
boost::program_options::options_description& config_file_options boost::program_options::options_description &cfg) {
)
{
return; return;
} }
} } // graphene::app }} // namespace graphene::app

View file

@ -1,3 +1,7 @@
#ifndef HARDFORK_1000_TIME #ifndef HARDFORK_1000_TIME
#define HARDFORK_1000_TIME (fc::time_point_sec( 1540000000 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_1000_TIME (fc::time_point_sec::from_iso_string("2018-10-20T01:46:40"))
#else
#define HARDFORK_1000_TIME (fc::time_point_sec::from_iso_string("2019-02-18T12:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// added delete sport and delete event group operations // added delete sport and delete event group operations
#ifndef HARDFORK_1001_TIME #ifndef HARDFORK_1001_TIME
#define HARDFORK_1001_TIME (fc::time_point_sec( 1540000000 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_1001_TIME (fc::time_point_sec::from_iso_string("2018-10-20T01:46:40"))
#else
#define HARDFORK_1001_TIME (fc::time_point_sec::from_iso_string("2019-02-18T12:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #357 Disallow publishing certain malformed price feeds // #357 Disallow publishing certain malformed price feeds
#ifndef HARDFORK_357_TIME #ifndef HARDFORK_357_TIME
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_357_TIME (fc::time_point_sec::from_iso_string("2015-10-09T18:45:00"))
#else
#define HARDFORK_357_TIME (fc::time_point_sec::from_iso_string("2015-10-09T18:45:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #359 Allow digits in asset name // #359 Allow digits in asset name
#ifndef HARDFORK_359_TIME #ifndef HARDFORK_359_TIME
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_359_TIME (fc::time_point_sec::from_iso_string("2015-10-09T18:45:00"))
#else
#define HARDFORK_359_TIME (fc::time_point_sec::from_iso_string("2015-10-09T18:45:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #385 October 23 enforce PARENT.CHILD and allow short names // #385 October 23 enforce PARENT.CHILD and allow short names
#ifndef HARDFORK_385_TIME #ifndef HARDFORK_385_TIME
#define HARDFORK_385_TIME (fc::time_point_sec( 1445558400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_385_TIME (fc::time_point_sec::from_iso_string("2015-10-23T00:00:00"))
#else
#define HARDFORK_385_TIME (fc::time_point_sec::from_iso_string("2015-10-23T00:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #409 Allow creation of sub-assets // #409 Allow creation of sub-assets
#ifndef HARDFORK_409_TIME #ifndef HARDFORK_409_TIME
#define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_409_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#else
#define HARDFORK_409_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #413 Add operation to claim asset fees // #413 Add operation to claim asset fees
#ifndef HARDFORK_413_TIME #ifndef HARDFORK_413_TIME
#define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_413_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#else
#define HARDFORK_413_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #415 Default accept policy for asset with no whitelist authorities // #415 Default accept policy for asset with no whitelist authorities
#ifndef HARDFORK_415_TIME #ifndef HARDFORK_415_TIME
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_415_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#else
#define HARDFORK_415_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #416 enforce_white_list is inconsistently applied // #416 enforce_white_list is inconsistently applied
#ifndef HARDFORK_416_TIME #ifndef HARDFORK_416_TIME
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_416_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#else
#define HARDFORK_416_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #419 Account can pay fees in blacklisted asset // #419 Account can pay fees in blacklisted asset
#ifndef HARDFORK_419_TIME #ifndef HARDFORK_419_TIME
#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_419_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#else
#define HARDFORK_419_TIME (fc::time_point_sec::from_iso_string("2015-11-04T16:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #436 Prevent margin call from being triggered unless feed < call price // #436 Prevent margin call from being triggered unless feed < call price
#ifndef HARDFORK_436_TIME #ifndef HARDFORK_436_TIME
#define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_436_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#else
#define HARDFORK_436_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #445 Refund create order fees on cancel // #445 Refund create order fees on cancel
#ifndef HARDFORK_445_TIME #ifndef HARDFORK_445_TIME
#define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_445_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#else
#define HARDFORK_445_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #453 Hardfork to retroactively correct referral percentages // #453 Hardfork to retroactively correct referral percentages
#ifndef HARDFORK_453_TIME #ifndef HARDFORK_453_TIME
#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_453_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#else
#define HARDFORK_453_TIME (fc::time_point_sec::from_iso_string("2015-12-16T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #480 Fix non-BTS MIA core_exchange_rate check // #480 Fix non-BTS MIA core_exchange_rate check
#ifndef HARDFORK_480_TIME #ifndef HARDFORK_480_TIME
#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_480_TIME (fc::time_point_sec::from_iso_string("2015-12-17T19:00:00"))
#else
#define HARDFORK_480_TIME (fc::time_point_sec::from_iso_string("2015-12-17T19:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #483 Operation history numbering change // #483 Operation history numbering change
#ifndef HARDFORK_483_TIME #ifndef HARDFORK_483_TIME
#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_483_TIME (fc::time_point_sec::from_iso_string("2015-12-17T19:00:00"))
#else
#define HARDFORK_483_TIME (fc::time_point_sec::from_iso_string("2015-12-17T19:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,7 @@
// 5050_1 HARDFORK Wednesday, 15 April 2020 20:00:00 GMT
#ifndef HARDFORK_5050_1_TIME #ifndef HARDFORK_5050_1_TIME
#define HARDFORK_5050_1_TIME (fc::time_point_sec( 1586980800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_5050_1_TIME (fc::time_point_sec::from_iso_string("2020-04-15T20:00:00"))
#else
#define HARDFORK_5050_1_TIME (fc::time_point_sec::from_iso_string("2020-04-22T20:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #516 Special authorities // #516 Special authorities
#ifndef HARDFORK_516_TIME #ifndef HARDFORK_516_TIME
#define HARDFORK_516_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_516_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_516_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #533 Improve vote counting implementation // #533 Improve vote counting implementation
#ifndef HARDFORK_533_TIME #ifndef HARDFORK_533_TIME
#define HARDFORK_533_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_533_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_533_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #538 Buyback accounts // #538 Buyback accounts
#ifndef HARDFORK_538_TIME #ifndef HARDFORK_538_TIME
#define HARDFORK_538_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_538_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_538_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #555 Buyback accounts // #555 Buyback accounts
#ifndef HARDFORK_555_TIME #ifndef HARDFORK_555_TIME
#define HARDFORK_555_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_555_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_555_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #563 Stealth fee routing // #563 Stealth fee routing
#ifndef HARDFORK_563_TIME #ifndef HARDFORK_563_TIME
#define HARDFORK_563_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_563_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_563_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #572 Allow asset to update permission flags when no supply exists // #572 Allow asset to update permission flags when no supply exists
#ifndef HARDFORK_572_TIME #ifndef HARDFORK_572_TIME
#define HARDFORK_572_TIME (fc::time_point_sec( 1456250400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_572_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#else
#define HARDFORK_572_TIME (fc::time_point_sec::from_iso_string("2016-02-23T18:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #599 Unpacking of extension is incorrect // #599 Unpacking of extension is incorrect
#ifndef HARDFORK_599_TIME #ifndef HARDFORK_599_TIME
#define HARDFORK_599_TIME (fc::time_point_sec( 1459789200 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_599_TIME (fc::time_point_sec::from_iso_string("2016-04-04T17:00:00"))
#else
#define HARDFORK_599_TIME (fc::time_point_sec::from_iso_string("2016-04-04T17:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #607 Disable negative voting on workers // #607 Disable negative voting on workers
#ifndef HARDFORK_607_TIME #ifndef HARDFORK_607_TIME
#define HARDFORK_607_TIME (fc::time_point_sec( 1458752400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_607_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#else
#define HARDFORK_607_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #613 Deprecate annual membership // #613 Deprecate annual membership
#ifndef HARDFORK_613_TIME #ifndef HARDFORK_613_TIME
#define HARDFORK_613_TIME (fc::time_point_sec( 1458752400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_613_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#else
#define HARDFORK_613_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// #615 Fix price feed expiration check, so websocket server will never spam too much data // #615 Fix price feed expiration check, so websocket server will never spam too much data
#ifndef HARDFORK_615_TIME #ifndef HARDFORK_615_TIME
#define HARDFORK_615_TIME (fc::time_point_sec( 1458752400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_615_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#else
#define HARDFORK_615_TIME (fc::time_point_sec::from_iso_string("2016-03-23T17:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// Placeholder HF for affiliate reward system // Placeholder HF for affiliate reward system
#ifndef HARDFORK_999_TIME #ifndef HARDFORK_999_TIME
#define HARDFORK_999_TIME (fc::time_point_sec( 1540000000 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_999_TIME (fc::time_point_sec::from_iso_string("2018-10-20T01:46:40"))
#else
#define HARDFORK_999_TIME (fc::time_point_sec::from_iso_string("2019-02-18T12:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,8 @@
// bitshares-core #429 rounding issue when creating assets // bitshares-core #429 rounding issue when creating assets
#ifndef HARDFORK_CORE_429_TIME #ifndef HARDFORK_CORE_429_TIME
#define HARDFORK_CORE_429_TIME (fc::time_point_sec( 1566784800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_CORE_429_TIME (fc::time_point_sec::from_iso_string("2019-08-26T02:00:00"))
#else
#define HARDFORK_CORE_429_TIME (fc::time_point_sec::from_iso_string("2019-09-13T02:00:00"))
#endif
#endif #endif

View file

@ -1,6 +1,10 @@
// #210 Check authorities on custom_operation // #210 Check authorities on custom_operation
#ifndef HARDFORK_CORE_210_TIME #ifndef HARDFORK_CORE_210_TIME
#define HARDFORK_CORE_210_TIME (fc::time_point_sec(1893456000)) // Jan 1 00:00:00 2030 (Not yet scheduled) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_CORE_210_TIME (fc::time_point_sec::from_iso_string("2030-01-01T00:00:00")) // (Not yet scheduled)
#else
#define HARDFORK_CORE_210_TIME (fc::time_point_sec::from_iso_string("2030-01-01T00:00:00")) // (Not yet scheduled)
#endif
// Bugfix: pre-HF 210, custom_operation's required_auths field was ignored. // Bugfix: pre-HF 210, custom_operation's required_auths field was ignored.
#define MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time) (chain_time <= HARDFORK_CORE_210_TIME) #define MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time) (chain_time <= HARDFORK_CORE_210_TIME)
#endif #endif

View file

@ -1,4 +1,7 @@
// GPOS HARDFORK Monday, 6 January 2020 01:00:00 GMT
#ifndef HARDFORK_GPOS_TIME #ifndef HARDFORK_GPOS_TIME
#define HARDFORK_GPOS_TIME (fc::time_point_sec( 1578272400 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_GPOS_TIME (fc::time_point_sec::from_iso_string("2020-01-06T01:00:00"))
#else
#define HARDFORK_GPOS_TIME (fc::time_point_sec::from_iso_string("2020-02-17T22:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,7 @@
// NFT HARDFORK Sat, 15-Aug-20 00:00:00 UTC
#ifndef HARDFORK_NFT_TIME #ifndef HARDFORK_NFT_TIME
#define HARDFORK_NFT_TIME (fc::time_point_sec( 1597449600 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_NFT_TIME (fc::time_point_sec::from_iso_string("2020-08-15T00:00:00"))
#else
#define HARDFORK_NFT_TIME (fc::time_point_sec::from_iso_string("2020-12-21T00:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,7 @@
// SON HARDFORK Wednesday, October 28, 2020 0:00:00 GMT
#ifndef HARDFORK_SON_TIME #ifndef HARDFORK_SON_TIME
#define HARDFORK_SON_TIME (fc::time_point_sec( 1603843200 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SON_TIME (fc::time_point_sec::from_iso_string("2020-10-28T00:00:00"))
#else
#define HARDFORK_SON_TIME (fc::time_point_sec::from_iso_string("2020-12-21T00:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,7 @@
// SON2 HARDFORK Saturday, July 31, 2021 00:00:00 GMT
#ifndef HARDFORK_SON2_TIME #ifndef HARDFORK_SON2_TIME
#define HARDFORK_SON2_TIME (fc::time_point_sec( 1627689600 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SON2_TIME (fc::time_point_sec::from_iso_string("2021-07-31T00:00:00"))
#else
#define HARDFORK_SON2_TIME (fc::time_point_sec::from_iso_string("2021-07-31T00:00:00"))
#endif
#endif #endif

View file

@ -1,4 +1,7 @@
// Wednesday, March 31, 2021 0:00:00
#ifndef HARDFORK_SON_FOR_HIVE_TIME #ifndef HARDFORK_SON_FOR_HIVE_TIME
#define HARDFORK_SON_FOR_HIVE_TIME (fc::time_point_sec( 1617148800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SON_FOR_HIVE_TIME (fc::time_point_sec::from_iso_string("2021-03-31T00:00:00"))
#else
#define HARDFORK_SON_FOR_HIVE_TIME (fc::time_point_sec::from_iso_string("2021-12-11T00:00:00"))
#endif
#endif #endif

View file

@ -1,3 +1,7 @@
#ifndef HARDFORK_SWEEPS_TIME #ifndef HARDFORK_SWEEPS_TIME
#define HARDFORK_SWEEPS_TIME (fc::time_point_sec( 1566784800 )) #ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SWEEPS_TIME (fc::time_point_sec::from_iso_string("2019-08-26T02:00:00"))
#else
#define HARDFORK_SWEEPS_TIME (fc::time_point_sec::from_iso_string("2019-09-13T02:00:00"))
#endif
#endif #endif

View file

@ -23,8 +23,13 @@
*/ */
#pragma once #pragma once
#ifdef BUILD_PEERPLAYS_TESTNET
#define GRAPHENE_SYMBOL "TEST" #define GRAPHENE_SYMBOL "TEST"
#define GRAPHENE_ADDRESS_PREFIX "TEST" #define GRAPHENE_ADDRESS_PREFIX "TEST"
#else
#define GRAPHENE_SYMBOL "PPY"
#define GRAPHENE_ADDRESS_PREFIX "PPY"
#endif
#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 #define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1
#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 #define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63