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
) )

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -25,36 +25,36 @@
#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;
seen.insert(name); seen.insert(name);
return modifier ? modifier(o) : o; return modifier ? modifier(o) : o;
@ -62,15 +62,14 @@ public:
private: private:
boost::container::flat_set<std::string> seen; boost::container::flat_set<std::string> seen;
const boost::shared_ptr<bpo::option_description> (*modifier)(const boost::shared_ptr<bpo::option_description>&); const boost::shared_ptr<bpo::option_description> (*modifier)(const boost::shared_ptr<bpo::option_description> &);
}; };
// Currently, you can only specify the filenames and logging levels, which // Currently, you can only specify the filenames and logging levels, which
// 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,26 +114,22 @@ 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;
const std::string console_appender_section_prefix = "log.console_appender."; const std::string console_appender_section_prefix = "log.console_appender.";
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");
@ -142,20 +137,18 @@ static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const
// stdout/stderr will be taken from ini file, everything else hard-coded here // stdout/stderr will be taken from ini file, everything else hard-coded here
fc::console_appender::config console_appender_config; fc::console_appender::config console_appender_config;
console_appender_config.level_colors.emplace_back( console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::debug, fc::console_appender::level_color(fc::log_level::debug,
fc::console_appender::color::green)); fc::console_appender::color::green));
console_appender_config.level_colors.emplace_back( console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::warn, fc::console_appender::level_color(fc::log_level::warn,
fc::console_appender::color::brown)); fc::console_appender::color::brown));
console_appender_config.level_colors.emplace_back( console_appender_config.level_colors.emplace_back(
fc::console_appender::level_color(fc::log_level::error, fc::console_appender::level_color(fc::log_level::error,
fc::console_appender::color::cyan)); fc::console_appender::color::cyan));
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,74 +188,66 @@ 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)
unique_options.add( od ); continue;
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);
auto modify_option_defaults = [](const boost::shared_ptr<bpo::option_description>& o) -> const boost::shared_ptr<bpo::option_description> { auto modify_option_defaults = [](const boost::shared_ptr<bpo::option_description> &o) -> const boost::shared_ptr<bpo::option_description> {
const std::string& name = o->long_name(); const std::string &name = o->long_name();
if( name == "partial-operations" ) if (name == "partial-operations")
return new_option_description(name, bpo::value<bool>()->default_value(true), o->description() ); return new_option_description(name, bpo::value<bool>()->default_value(true), o->description());
if( name == "max-ops-per-account" ) if (name == "max-ops-per-account")
return new_option_description(name, bpo::value<int>()->default_value(100), o->description() ); return new_option_description(name, bpo::value<int>()->default_value(100), o->description());
return o; return o;
}; };
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
{ {
out_cfg << "\n"; out_cfg << "\n";
out_cfg << "# " << plugin_header_surrounding << "\n"; out_cfg << "# " << plugin_header_surrounding << "\n";
@ -274,20 +257,21 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
continue; continue;
} }
if( !od->description().empty() ) if (!od->description().empty())
out_cfg << "# " << od->description() << "\n"; out_cfg << "# " << od->description() << "\n";
boost::any store; boost::any store;
if( !od->semantic()->apply_default(store) ) if (!od->semantic()->apply_default(store))
out_cfg << "# " << od->long_name() << " = \n"; out_cfg << "# " << od->long_name() << " = \n";
else { else {
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);
example.erase(example.length()-1); example.erase(example.length() - 1);
out_cfg << od->long_name() << " = " << example << "\n"; out_cfg << od->long_name() << " = " << example << "\n";
} }
} }
@ -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,36 +301,29 @@ 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)) {
} // create default config.ini and logging.ini
else if(!exists(config_ini_path)) create_new_config_file(config_ini_path, data_dir, cfg_options);
{ create_logging_config_file(logging_ini_path, data_dir);
// create default config.ini and logging.ini
create_new_config_file(config_ini_path, data_dir, cfg_options);
create_logging_config_file(logging_ini_path, data_dir);
}
// load witness node configuration
load_config_file(config_ini_path, cfg_options, options);
// load logging configuration
if (fc::exists(logging_ini_path))
{
load_logging_config_file(logging_ini_path);
}
else
{
// this is the legacy config.ini case
load_logging_config_file(config_ini_path);
}
} }
} } // graphene::app // load witness node configuration
load_config_file(config_ini_path, cfg_options, options);
// load logging configuration
if (fc::exists(logging_ini_path)) {
load_logging_config_file(logging_ini_path);
} else {
// this is the legacy config.ini case
load_logging_config_file(config_ini_path);
}
}
}} // 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>
@ -52,55 +52,52 @@
#include <vector> #include <vector>
namespace graphene { namespace app { namespace graphene { namespace app {
using namespace graphene::chain; using namespace graphene::chain;
using namespace graphene::market_history; using namespace graphene::market_history;
using namespace graphene::accounts_list; using namespace graphene::accounts_list;
using namespace fc::ecc; using namespace fc::ecc;
using namespace std; using namespace std;
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
{
bool success;
uint64_t min_val;
uint64_t max_val;
uint64_t value_out;
fc::ecc::blind_factor_type blind_out;
string message_out;
};
struct account_asset_balance struct verify_range_proof_rewind_result {
{ bool success;
string name; uint64_t min_val;
account_id_type account_id; uint64_t max_val;
share_type amount; uint64_t value_out;
}; fc::ecc::blind_factor_type blind_out;
struct asset_holders string message_out;
{ };
asset_id_type asset_id;
int count; struct account_asset_balance {
}; string name;
account_id_type account_id;
/** share_type amount;
};
struct asset_holders {
asset_id_type asset_id;
int count;
};
/**
* @brief The history_api class implements the RPC API for account history * @brief The history_api class implements the RPC API for account history
* *
* 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),
:_app(app), database_api( std::ref(*app.chain_database())) {} database_api(std::ref(*app.chain_database())) {
}
/** /**
* @brief Get operations relevant to the specificed account * @brief Get operations relevant to the specificed account
* @param account_id_or_name The account ID or name whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param stop ID of the earliest operation to retrieve * @param stop ID of the earliest operation to retrieve
@ -108,12 +105,12 @@ namespace graphene { namespace app {
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history(const std::string account_id_or_name, vector<operation_history_object> get_account_history(const std::string account_id_or_name,
operation_history_id_type stop = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(),
unsigned limit = 100, unsigned limit = 100,
operation_history_id_type start = operation_history_id_type())const; operation_history_id_type start = operation_history_id_type()) const;
/** /**
* @brief Get only asked operations relevant to the specified account * @brief Get only asked operations relevant to the specified account
* @param account_id_or_name The account ID or name whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...) * @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...)
@ -122,13 +119,13 @@ namespace graphene { namespace app {
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history_operations(const std::string account_id_or_name, vector<operation_history_object> get_account_history_operations(const std::string account_id_or_name,
int operation_id, int operation_id,
operation_history_id_type start = operation_history_id_type(), operation_history_id_type start = operation_history_id_type(),
operation_history_id_type stop = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(),
unsigned limit = 100)const; unsigned limit = 100) const;
/** /**
* @breif Get operations relevant to the specified account referenced * @breif Get operations relevant to the specified account referenced
* by an event numbering specific to the account. The current number of operations * by an event numbering specific to the account. The current number of operations
* for the account can be found in the account statistics (or use 0 for start). * for the account can be found in the account statistics (or use 0 for start).
@ -140,82 +137,79 @@ namespace graphene { namespace app {
* 0 is default, which will start querying from the most recent operation. * 0 is default, which will start querying from the most recent operation.
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_relative_account_history( const std::string account_id_or_name, vector<operation_history_object> get_relative_account_history(const std::string account_id_or_name,
uint32_t stop = 0, uint32_t stop = 0,
unsigned limit = 100, unsigned limit = 100,
uint32_t start = 0) const; uint32_t start = 0) const;
vector<order_history_object> get_fill_order_history( std::string asset_a, std::string asset_b, uint32_t limit )const; vector<order_history_object> get_fill_order_history(std::string asset_a, std::string asset_b, uint32_t limit) const;
vector<bucket_object> get_market_history( std::string asset_a, std::string asset_b, uint32_t bucket_seconds, vector<bucket_object> 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; fc::time_point_sec start, fc::time_point_sec end) const;
vector<account_balance_object> list_core_accounts()const; vector<account_balance_object> list_core_accounts() const;
flat_set<uint32_t> get_market_history_buckets()const; flat_set<uint32_t> get_market_history_buckets() const;
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:
application& _app;
graphene::app::database_api database_api;
};
/** private:
application &_app;
graphene::app::database_api database_api;
};
/**
* @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();
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const; vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to) const;
private: private:
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; processed_transaction trx;
processed_transaction trx; };
};
typedef std::function<void(variant/*transaction_confirmation*/)> confirmation_callback; typedef std::function<void(variant /*transaction_confirmation*/)> confirmation_callback;
/** /**
* @brief Broadcast a transaction to the network * @brief Broadcast a transaction to the network
* @param trx The transaction to broadcast * @param trx The transaction to broadcast
* *
* The transaction will be checked for validity in the local database prior to broadcasting. If it fails to * The transaction will be checked for validity in the local database prior to broadcasting. If it fails to
* apply locally, an error will be thrown and the transaction will not be broadcast. * apply locally, an error will be thrown and the transaction will not be broadcast.
*/ */
void broadcast_transaction(const signed_transaction& trx); void broadcast_transaction(const signed_transaction &trx);
/** this version of broadcast transaction registers a callback method that will be called when the transaction is /** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the * included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block. * block.
*/ */
void broadcast_transaction_with_callback( confirmation_callback cb, const signed_transaction& trx); void broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction &trx);
/** this version of broadcast transaction registers a callback method that will be called when the transaction is /** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the * included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block. * block.
*/ */
fc::variant broadcast_transaction_synchronous(const signed_transaction& trx); fc::variant broadcast_transaction_synchronous(const signed_transaction &trx);
void broadcast_block( const signed_block& block ); void broadcast_block(const signed_block &block);
/** /**
* @brief Not reflected, thus not accessible to API clients. * @brief Not reflected, thus not accessible to API clients.
* *
* This function is registered to receive the applied_block * This function is registered to receive the applied_block
@ -223,147 +217,144 @@ namespace graphene { namespace app {
* It then dispatches callbacks to clients who have requested * It then dispatches callbacks to clients who have requested
* 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:
boost::signals2::scoped_connection _applied_block_connection;
map<transaction_id_type,confirmation_callback> _callbacks;
application& _app;
};
/** private:
boost::signals2::scoped_connection _applied_block_connection;
map<transaction_id_type, confirmation_callback> _callbacks;
application &_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);
/** /**
* @brief Return general network information, such as p2p port * @brief Return general network information, such as p2p port
*/ */
fc::variant_object get_info() const; fc::variant_object get_info() const;
/** /**
* @brief add_node Connect to a new peer * @brief add_node Connect to a new peer
* @param ep The IP/Port of the peer to connect to * @param ep The IP/Port of the peer to connect to
*/ */
void add_node(const fc::ip::endpoint& ep); void add_node(const fc::ip::endpoint &ep);
/** /**
* @brief Get status of all current connections to peers * @brief Get status of all current connections to peers
*/ */
std::vector<net::peer_status> get_connected_peers() const; std::vector<net::peer_status> get_connected_peers() const;
/** /**
* @brief Get advanced node parameters, such as desired and max * @brief Get advanced node parameters, such as desired and max
* number of connections * number of connections
*/ */
fc::variant_object get_advanced_node_parameters() const; fc::variant_object get_advanced_node_parameters() const;
/** /**
* @brief Set advanced node parameters, such as desired and max * @brief Set advanced node parameters, such as desired and max
* number of connections * number of connections
* @param params a JSON object containing the name/value pairs for the parameters to set * @param params a JSON object containing the name/value pairs for the parameters to set
*/ */
void set_advanced_node_parameters(const fc::variant_object& params); void set_advanced_node_parameters(const fc::variant_object &params);
/**
* @brief Return list of potential peers
*/
std::vector<net::potential_peer_record> get_potential_peers() const;
/**
* @brief Return list of pending transactions.
*/
map<transaction_id_type, signed_transaction> list_pending_transactions() const;
/**
* @brief Subscribes caller for notifications about pending transactions.
* @param callback a functional object which will be called when new transaction is created.
*/
void subscribe_to_pending_transactions(std::function<void(const variant&)> callback);
/**
* @brief Unsubscribes caller from notifications about pending transactions.
*/
void unsubscribe_from_pending_transactions();
private:
application& _app;
map<transaction_id_type, signed_transaction> _pending_transactions;
boost::signals2::scoped_connection _pending_trx_connection;
boost::signals2::scoped_connection _applied_block_connection;
std::function<void(const variant&)> _on_pending_transaction;
};
class crypto_api
{
public:
crypto_api();
fc::ecc::commitment_type blind( const fc::ecc::blind_factor_type& blind, uint64_t value );
fc::ecc::blind_factor_type blind_sum( const std::vector<blind_factor_type>& blinds_in, uint32_t non_neg );
bool verify_sum( const std::vector<commitment_type>& commits_in, const std::vector<commitment_type>& neg_commits_in, int64_t excess );
verify_range_result verify_range( const fc::ecc::commitment_type& commit, const std::vector<char>& proof );
std::vector<char> range_proof_sign( uint64_t min_value,
const commitment_type& commit,
const blind_factor_type& commit_blind,
const blind_factor_type& nonce,
int8_t base10_exp,
uint8_t min_bits,
uint64_t actual_value );
verify_range_proof_rewind_result verify_range_proof_rewind( const blind_factor_type& nonce,
const fc::ecc::commitment_type& commit,
const std::vector<char>& proof );
range_proof_info range_get_info( const std::vector<char>& proof );
};
/** /**
* @brief Return list of potential peers
*/
std::vector<net::potential_peer_record> get_potential_peers() const;
/**
* @brief Return list of pending transactions.
*/
map<transaction_id_type, signed_transaction> list_pending_transactions() const;
/**
* @brief Subscribes caller for notifications about pending transactions.
* @param callback a functional object which will be called when new transaction is created.
*/
void subscribe_to_pending_transactions(std::function<void(const variant &)> callback);
/**
* @brief Unsubscribes caller from notifications about pending transactions.
*/
void unsubscribe_from_pending_transactions();
private:
application &_app;
map<transaction_id_type, signed_transaction> _pending_transactions;
boost::signals2::scoped_connection _pending_trx_connection;
boost::signals2::scoped_connection _applied_block_connection;
std::function<void(const variant &)> _on_pending_transaction;
};
class crypto_api {
public:
crypto_api();
fc::ecc::commitment_type blind(const fc::ecc::blind_factor_type &blind, uint64_t value);
fc::ecc::blind_factor_type blind_sum(const std::vector<blind_factor_type> &blinds_in, uint32_t non_neg);
bool verify_sum(const std::vector<commitment_type> &commits_in, const std::vector<commitment_type> &neg_commits_in, int64_t excess);
verify_range_result verify_range(const fc::ecc::commitment_type &commit, const std::vector<char> &proof);
std::vector<char> range_proof_sign(uint64_t min_value,
const commitment_type &commit,
const blind_factor_type &commit_blind,
const blind_factor_type &nonce,
int8_t base10_exp,
uint8_t min_bits,
uint64_t actual_value);
verify_range_proof_rewind_result verify_range_proof_rewind(const blind_factor_type &nonce,
const fc::ecc::commitment_type &commit,
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();
/** /**
* @brief Get asset holders for a specific asset * @brief Get asset holders for a specific asset
* @param asset The specific asset id or symbol * @param asset The specific asset id or symbol
* @param start The start index * @param start The start index
* @param limit Maximum limit must not exceed 100 * @param limit Maximum limit must not exceed 100
* @return A list of asset holders for the specified asset * @return A list of asset holders for the specified asset
*/ */
vector<account_asset_balance> get_asset_holders( std::string asset, uint32_t start, uint32_t limit )const; vector<account_asset_balance> get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const;
/** /**
* @brief Get asset holders count for a specific asset * @brief Get asset holders count for a specific asset
* @param asset The specific asset id or symbol * @param asset The specific asset id or symbol
* @return Holders count for the specified asset * @return Holders count for the specified asset
*/ */
int get_asset_holders_count( std::string asset )const; int get_asset_holders_count(std::string asset) const;
/** /**
* @brief Get all asset holders * @brief Get all asset holders
* @return A list of all asset holders * @return A list of all asset holders
*/ */
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:
graphene::app::application& _app; private:
graphene::chain::database& _db; graphene::app::application &_app;
graphene::app::database_api database_api; graphene::chain::database &_db;
}; 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>;
@ -374,18 +365,17 @@ extern template class fc::api<graphene::app::asset_api>;
extern template class fc::api<graphene::debug_witness::debug_api>; extern template class fc::api<graphene::debug_witness::debug_api>;
namespace graphene { namespace app { namespace graphene { namespace app {
/** /**
* @brief The login_api class implements the bottom layer of the RPC API * @brief The login_api class implements the bottom layer of the RPC API
* *
* 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();
/** /**
* @brief Authenticate to the RPC server * @brief Authenticate to the RPC server
* @param user Username to login with * @param user Username to login with
* @param password Password to login with * @param password Password to login with
@ -394,114 +384,120 @@ namespace graphene { namespace app {
* @note This must be called prior to requesting other APIs. Other APIs may not be accessible until the client * @note This must be called prior to requesting other APIs. Other APIs may not be accessible until the client
* has sucessfully authenticated. * has sucessfully authenticated.
*/ */
bool login(const string& user, const string& password); bool login(const string &user, const string &password);
/// @brief Retrieve the network block API /// @brief Retrieve the network block API
fc::api<block_api> block()const; fc::api<block_api> block() const;
/// @brief Retrieve the network broadcast API /// @brief Retrieve the network broadcast API
fc::api<network_broadcast_api> network_broadcast()const; fc::api<network_broadcast_api> network_broadcast() const;
/// @brief Retrieve the database API /// @brief Retrieve the database API
fc::api<database_api> database()const; fc::api<database_api> database() const;
/// @brief Retrieve the history API /// @brief Retrieve the history API
fc::api<history_api> history()const; fc::api<history_api> history() const;
/// @brief Retrieve the network node API /// @brief Retrieve the network node API
fc::api<network_node_api> network_node()const; fc::api<network_node_api> network_node() const;
/// @brief Retrieve the cryptography API /// @brief Retrieve the cryptography API
fc::api<crypto_api> crypto()const; fc::api<crypto_api> crypto() const;
/// @brief Retrieve the asset API /// @brief Retrieve the asset API
fc::api<asset_api> asset()const; fc::api<asset_api> asset() const;
/// @brief Retrieve the debug API (if available) /// @brief Retrieve the debug API (if available)
fc::api<graphene::debug_witness::debug_api> debug()const; fc::api<graphene::debug_witness::debug_api> debug() const;
/// @brief Retrieve the bookie API (if available) /// @brief Retrieve the bookie API (if available)
fc::api<graphene::bookie::bookie_api> bookie()const; fc::api<graphene::bookie::bookie_api> bookie() const;
/// @brief Retrieve the affiliate_stats API (if available) /// @brief Retrieve the affiliate_stats API (if available)
fc::api<graphene::affiliate_stats::affiliate_stats_api> affiliate_stats()const; fc::api<graphene::affiliate_stats::affiliate_stats_api> affiliate_stats() const;
/// @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:
application& _app; private:
optional< fc::api<block_api> > _block_api; application &_app;
optional< fc::api<database_api> > _database_api; optional<fc::api<block_api>> _block_api;
optional< fc::api<network_broadcast_api> > _network_broadcast_api; optional<fc::api<database_api>> _database_api;
optional< fc::api<network_node_api> > _network_node_api; optional<fc::api<network_broadcast_api>> _network_broadcast_api;
optional< fc::api<history_api> > _history_api; optional<fc::api<network_node_api>> _network_node_api;
optional< fc::api<crypto_api> > _crypto_api; optional<fc::api<history_api>> _history_api;
optional< fc::api<asset_api> > _asset_api; optional<fc::api<crypto_api>> _crypto_api;
optional< fc::api<graphene::debug_witness::debug_api> > _debug_api; optional<fc::api<asset_api>> _asset_api;
optional< fc::api<graphene::bookie::bookie_api> > _bookie_api; optional<fc::api<graphene::debug_witness::debug_api>> _debug_api;
optional< fc::api<graphene::affiliate_stats::affiliate_stats_api> > _affiliate_stats_api; optional<fc::api<graphene::bookie::bookie_api>> _bookie_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>;
FC_REFLECT( graphene::app::network_broadcast_api::transaction_confirmation, // clang-format off
(id)(block_num)(trx_num)(trx) )
FC_REFLECT( graphene::app::verify_range_result,
(success)(min_val)(max_val) )
FC_REFLECT( graphene::app::verify_range_proof_rewind_result,
(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::network_broadcast_api::transaction_confirmation,
FC_REFLECT( graphene::app::asset_holders, (asset_id)(count) ); (id)(block_num)(trx_num)(trx))
FC_REFLECT(graphene::app::verify_range_result,
(success)(min_val)(max_val))
FC_REFLECT(graphene::app::verify_range_proof_rewind_result,
(success)(min_val)(max_val)(value_out)(blind_out)(message_out))
FC_REFLECT(graphene::app::account_asset_balance,
(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)
(get_account_history_operations) (get_account_history_operations)
(get_relative_account_history) (get_relative_account_history)
(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)
(get_connected_peers) (get_connected_peers)
(get_potential_peers) (get_potential_peers)
(get_advanced_node_parameters) (get_advanced_node_parameters)
(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)
(verify_sum) (verify_sum)
(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)
(network_broadcast) (network_broadcast)
(database) (database)
(history) (history)
(network_node) (network_node)
(crypto) (crypto)
(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,89 +24,86 @@
#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 {
using std::string; class application_impl;
}
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();
void shutdown(); void shutdown();
void startup_plugins(); void startup_plugins();
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()); _cfg_options.add(plugin_cfg_options);
_cfg_options.add(plugin_cfg_options); }
}
add_available_plugin( plug ); add_available_plugin(plug);
return plug; return plug;
} }
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>() ); return result;
return result; }
}
net::node_ptr p2p_node(); net::node_ptr p2p_node();
std::shared_ptr<chain::database> chain_database()const; std::shared_ptr<chain::database> chain_database() const;
void set_block_production(bool producing_blocks); void set_block_production(bool producing_blocks);
fc::optional< api_access_info > get_api_access_info( const string& username )const; fc::optional<api_access_info> get_api_access_info(const string &username) const;
void set_api_access_info(const string& username, api_access_info&& permissions); void set_api_access_info(const string &username, api_access_info &&permissions);
bool is_finished_syncing()const; bool is_finished_syncing() const;
/// Emitted when syncing finishes (is_finished_syncing will return true) /// Emitted when syncing finishes (is_finished_syncing will return true)
boost::signals2::signal<void()> syncing_finished; boost::signals2::signal<void()> syncing_finished;
void enable_plugin( const string& name ); void enable_plugin(const string &name);
bool is_plugin_enabled(const string& name) const; bool is_plugin_enabled(const string &name) const;
std::shared_ptr<fc::thread> elasticsearch_thread; std::shared_ptr<fc::thread> elasticsearch_thread;
private: private:
void add_available_plugin( std::shared_ptr<abstract_plugin> p ); void add_available_plugin(std::shared_ptr<abstract_plugin> p);
std::shared_ptr<detail::application_impl> my; std::shared_ptr<detail::application_impl> my;
boost::program_options::options_description _cli_options; boost::program_options::options_description _cli_options;
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

File diff suppressed because it is too large Load diff

View file

@ -24,51 +24,53 @@
#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; string referrer_name;
string referrer_name; string lifetime_referrer_name;
string lifetime_referrer_name; vector<variant> votes;
vector<variant> votes; optional<vesting_balance_object> cashback_balance;
optional<vesting_balance_object> cashback_balance; vector<account_balance_object> balances;
vector<account_balance_object> balances; vector<vesting_balance_object> vesting_balances;
vector<vesting_balance_object> vesting_balances; vector<limit_order_object> limit_orders;
vector<limit_order_object> limit_orders; vector<call_order_object> call_orders;
vector<call_order_object> call_orders; vector<force_settlement_object> settle_orders;
vector<force_settlement_object> settle_orders; vector<proposal_object> proposals;
vector<proposal_object> proposals; vector<asset_id_type> assets;
vector<asset_id_type> assets; vector<withdraw_permission_object> withdraws;
vector<withdraw_permission_object> withdraws; // vector<pending_dividend_payout_balance_object> pending_dividend_payments;
// vector<pending_dividend_payout_balance_object> pending_dividend_payments; 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
FC_REFLECT( graphene::app::full_account, // clang-format off
(account)
(statistics) FC_REFLECT(graphene::app::full_account,
(registrar_name) (account)
(referrer_name) (statistics)
(lifetime_referrer_name) (registrar_name)
(votes) (referrer_name)
(cashback_balance) (lifetime_referrer_name)
(balances) (votes)
(vesting_balances) (cashback_balance)
(limit_orders) (balances)
(call_orders) (vesting_balances)
(settle_orders) (limit_orders)
(proposals) (call_orders)
(assets) (settle_orders)
(withdraws) (proposals)
(pending_dividend_payments) (assets)
) (withdraws)
(pending_dividend_payments))
// clang-format on

View file

@ -30,118 +30,119 @@
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;
/** /**
* @brief Perform early startup routines and register plugin indexes, callbacks, etc. * @brief Perform early startup routines and register plugin indexes, callbacks, etc.
* *
* Plugins MUST supply a method initialize() which will be called early in the application startup. This method * Plugins MUST supply a method initialize() which will be called early in the application startup. This method
* should contain early setup code such as initializing variables, adding indexes to the database, registering * should contain early setup code such as initializing variables, adding indexes to the database, registering
* callback methods from the database, adding APIs, etc., as well as applying any options in the @ref options map * callback methods from the database, adding APIs, etc., as well as applying any options in the @ref options map
* *
* This method is called BEFORE the database is open, therefore any routines which require any chain state MUST * This method is called BEFORE the database is open, therefore any routines which require any chain state MUST
* NOT be called by this method. These routines should be performed in startup() instead. * NOT be called by this method. These routines should be performed in startup() instead.
* *
* @param options The options passed to the application, via configuration files or command line * @param options The options passed to the application, via configuration files or command line
*/ */
virtual void plugin_initialize( const boost::program_options::variables_map& options ) = 0; virtual void plugin_initialize(const boost::program_options::variables_map &options) = 0;
/** /**
* @brief Begin normal runtime operations * @brief Begin normal runtime operations
* *
* Plugins MUST supply a method startup() which will be called at the end of application startup. This method * Plugins MUST supply a method startup() which will be called at the end of application startup. This method
* should contain code which schedules any tasks, or requires chain state. * should contain code which schedules any tasks, or requires chain state.
*/ */
virtual void plugin_startup() = 0; virtual void plugin_startup() = 0;
/** /**
* @brief Cleanly shut down the plugin. * @brief Cleanly shut down the plugin.
* *
* This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM). * This is called to request a clean shutdown (e.g. due to SIGINT or SIGTERM).
*/ */
virtual void plugin_shutdown() = 0; virtual void plugin_shutdown() = 0;
/** /**
* @brief Register the application instance with the plugin. * @brief Register the application instance with the plugin.
* *
* This is called by the framework to set the application. * This is called by the framework to set the application.
*/ */
virtual void plugin_set_app( application* a ) = 0; virtual void plugin_set_app(application *a) = 0;
/** /**
* @brief Fill in command line parameters used by the plugin. * @brief Fill in command line parameters used by the plugin.
* *
* @param command_line_options All options this plugin supports taking on the command-line * @param command_line_options All options this plugin supports taking on the command-line
* @param config_file_options All options this plugin supports storing in a configuration file * @param config_file_options All options this plugin supports storing in a configuration file
* *
* This method populates its arguments with any * This method populates its arguments with any
* command-line and configuration file options the plugin supports. * command-line and configuration file options the plugin supports.
* 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;
virtual std::string plugin_name()const override; virtual std::string plugin_name() const override;
virtual std::string plugin_description()const override; virtual std::string plugin_description() const override;
virtual void plugin_initialize( const boost::program_options::variables_map& options ) override; virtual void plugin_initialize(const boost::program_options::variables_map &options) override;
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(); } chain::database &database() {
application& app()const { assert(_app); return *_app; } return *app().chain_database();
protected: }
net::node& p2p_node() { return *app().p2p_node(); } application &app() const {
assert(_app);
return *_app;
}
private: protected:
application* _app = nullptr; net::node &p2p_node() {
return *app().p2p_node();
}
private:
application *_app = nullptr;
}; };
/// @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) \
if( options.count(name) ) { \ if (options.count(name)) { \
const std::vector<std::string>& ops = options[name].as<std::vector<std::string>>(); \ const std::vector<std::string> &ops = options[name].as<std::vector<std::string>>(); \
std::transform(ops.begin(), ops.end(), std::inserter(container, container.end()), &graphene::app::impl::dejsonify<type>); \ std::transform(ops.begin(), ops.end(), std::inserter(container, container.end()), &graphene::app::impl::dejsonify<type>); \
} }
/// @} /// @}
} } //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