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()
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 (USE_PCH 1)
@ -242,3 +250,7 @@ endif(LINUX)
include(CPack)
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
cd peerplays
git submodule update --init --recursive
# If you want to build Mainnet node
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 install # this can install the executable files under /usr/local

View file

@ -1,4 +1,5 @@
#!/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

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
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/chain/config.hpp>
#include <fc/reflect/variant.hpp>
#include <fc/string.hpp>
#include <fc/exception/exception.hpp>
#include <fc/log/console_appender.hpp>
#include <fc/log/file_appender.hpp>
#include <fc/log/logger_config.hpp>
#include <fc/reflect/variant.hpp>
#include <fc/string.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <fstream>
namespace bpo = boost::program_options;
class deduplicator
{
class deduplicator {
public:
deduplicator() : modifier(nullptr) {}
deduplicator() :
modifier(nullptr) {
}
deduplicator(const boost::shared_ptr<bpo::option_description> (*mod_fn)(const boost::shared_ptr<bpo::option_description>&))
: modifier(mod_fn) {}
deduplicator(const boost::shared_ptr<bpo::option_description> (*mod_fn)(const boost::shared_ptr<bpo::option_description> &)) :
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();
if( seen.find( name ) != seen.end() )
if (seen.find(name) != seen.end())
return nullptr;
seen.insert(name);
return modifier ? modifier(o) : o;
@ -62,15 +62,14 @@ public:
private:
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
// are all most users would want to change. At a later time, options can
// be added to control rotation intervals, compression, and other seldom-
// 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"
"[log.console_appender.stderr]\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,
// so we do it by hand
static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const fc::path& config_ini_filename)
{
try
{
static fc::optional<fc::logging_config> load_logging_config_from_ini_file(const fc::path &config_ini_filename) {
try {
fc::logging_config logging_config;
bool found_logging_config = false;
boost::property_tree::ptree 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)
{
const std::string& section_name = section.first;
const boost::property_tree::ptree& section_tree = section.second;
for (const auto &section : config_ini_tree) {
const std::string &section_name = section.first;
const boost::property_tree::ptree &section_tree = section.second;
const std::string console_appender_section_prefix = "log.console_appender.";
const std::string file_appender_section_prefix = "log.file_appender.";
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 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);
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;
}
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());
fc::path file_name = section_tree.get<std::string>("filename");
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);
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;
}
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 level_string = section_tree.get<std::string>("level");
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, "")
}
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("");
helper.add_options()( name.c_str(), value, description.c_str() );
helper.add_options()(name.c_str(), value, description.c_str());
return helper.options()[0];
}
static void load_config_file(const fc::path& config_ini_path, const bpo::options_description& cfg_options,
bpo::variables_map& options )
{
static void load_config_file(const fc::path &config_ini_path, const bpo::options_description &cfg_options,
bpo::variables_map &options) {
deduplicator dedup;
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);
if( !od ) continue;
unique_options.add( od );
if (!od)
continue;
unique_options.add(od);
}
// get the basic options
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
{
try {
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);
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()));
}
return false;
}
static void create_new_config_file(const fc::path& config_ini_path, const fc::path& data_dir,
const bpo::options_description& cfg_options )
{
static void create_new_config_file(const fc::path &config_ini_path, const fc::path &data_dir,
const bpo::options_description &cfg_options) {
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);
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();
if( name == "partial-operations" )
return new_option_description(name, bpo::value<bool>()->default_value(true), o->description() );
if( name == "max-ops-per-account" )
return new_option_description(name, bpo::value<int>()->default_value(100), o->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();
if (name == "partial-operations")
return new_option_description(name, bpo::value<bool>()->default_value(true), o->description());
if (name == "max-ops-per-account")
return new_option_description(name, bpo::value<int>()->default_value(100), o->description());
return o;
};
deduplicator dedup(modify_option_defaults);
std::ofstream out_cfg(config_ini_path.preferred_string());
std::string plugin_header_surrounding( 78, '=' );
for( const boost::shared_ptr<bpo::option_description> opt : cfg_options.options() )
{
std::string plugin_header_surrounding(78, '=');
for (const boost::shared_ptr<bpo::option_description> opt : cfg_options.options()) {
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 << "# " << plugin_header_surrounding << "\n";
@ -274,20 +257,21 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa
continue;
}
if( !od->description().empty() )
if (!od->description().empty())
out_cfg << "# " << od->description() << "\n";
boost::any store;
if( !od->semantic()->apply_default(store) )
if (!od->semantic()->apply_default(store))
out_cfg << "# " << od->long_name() << " = \n";
else {
auto example = od->format_parameter();
if( example.empty() )
if (example.empty())
// This is a boolean switch
out_cfg << od->long_name() << " = " << "false\n";
out_cfg << od->long_name() << " = "
<< "false\n";
else {
// The string is formatted "arg (=<interesting part>)"
example.erase(0, 6);
example.erase(example.length()-1);
example.erase(example.length() - 1);
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();
}
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));
if (!exists(data_dir))
{
if (!exists(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 {
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 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
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_new_config_file(config_ini_path, data_dir, cfg_options);
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 logging configuration
if (fc::exists(logging_ini_path))
{
if (fc::exists(logging_ini_path)) {
load_logging_config_file(logging_ini_path);
}
else
{
} else {
// this is the legacy config.ini case
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/chain/protocol/types.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/market_history/market_history_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/bookie/bookie_api.hpp>
#include <graphene/debug_witness/debug_api.hpp>
#include <graphene/net/node.hpp>
#include <fc/api.hpp>
#include <fc/optional.hpp>
#include <fc/crypto/elliptic.hpp>
#include <fc/network/ip.hpp>
#include <fc/optional.hpp>
#include <boost/container/flat_set.hpp>
@ -52,53 +52,50 @@
#include <vector>
namespace graphene { namespace app {
using namespace graphene::chain;
using namespace graphene::market_history;
using namespace graphene::accounts_list;
using namespace fc::ecc;
using namespace std;
using namespace graphene::chain;
using namespace graphene::market_history;
using namespace graphene::accounts_list;
using namespace fc::ecc;
using namespace std;
class application;
class application;
struct verify_range_result
{
struct verify_range_result {
bool success;
uint64_t min_val;
uint64_t max_val;
};
};
struct verify_range_proof_rewind_result
{
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 account_asset_balance {
string name;
account_id_type account_id;
share_type amount;
};
struct asset_holders
{
};
struct asset_holders {
asset_id_type asset_id;
int count;
};
};
/**
/**
* @brief The history_api class implements the RPC API for account history
*
* This API contains methods to access account histories
*/
class history_api
{
public:
history_api(application& app)
:_app(app), database_api( std::ref(*app.chain_database())) {}
class history_api {
public:
history_api(application &app) :
_app(app),
database_api(std::ref(*app.chain_database())) {
}
/**
* @brief Get operations relevant to the specificed account
@ -111,7 +108,7 @@ namespace graphene { namespace app {
vector<operation_history_object> get_account_history(const std::string account_id_or_name,
operation_history_id_type stop = operation_history_id_type(),
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
@ -126,7 +123,7 @@ namespace graphene { namespace app {
int operation_id,
operation_history_id_type start = 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
@ -140,57 +137,54 @@ namespace graphene { namespace app {
* 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.
*/
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,
unsigned limit = 100,
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<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;
vector<account_balance_object> list_core_accounts()const;
flat_set<uint32_t> get_market_history_buckets()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,
fc::time_point_sec start, fc::time_point_sec end) const;
vector<account_balance_object> list_core_accounts() 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 = 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
*/
class block_api
{
public:
block_api(graphene::chain::database& db);
class block_api {
public:
block_api(graphene::chain::database &db);
~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:
graphene::chain::database& _db;
};
private:
graphene::chain::database &_db;
};
/**
/**
* @brief The network_broadcast_api class allows broadcasting of transactions.
*/
class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api>
{
public:
network_broadcast_api(application& a);
class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api> {
public:
network_broadcast_api(application &a);
struct transaction_confirmation
{
struct transaction_confirmation {
transaction_id_type id;
uint32_t block_num;
uint32_t trx_num;
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
@ -199,21 +193,21 @@ namespace graphene { namespace app {
* 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.
*/
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
* included into a block. The callback method includes the transaction id, block number, and transaction number in the
* 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
* included into a block. The callback method includes the transaction id, block number, and transaction number in the
* 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.
@ -223,20 +217,20 @@ namespace graphene { namespace app {
* It then dispatches callbacks to clients who have requested
* to be notified when a particular txid is included in a block.
*/
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;
};
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;
};
/**
* @brief The network_node_api class allows maintenance of p2p connections.
*/
class network_node_api
{
public:
network_node_api(application& a);
class network_node_api {
public:
network_node_api(application &a);
/**
* @brief Return general network information, such as p2p port
@ -247,7 +241,7 @@ namespace graphene { namespace app {
* @brief add_node Connect to a new peer
* @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
@ -265,7 +259,7 @@ namespace graphene { namespace app {
* number of connections
* @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
@ -281,58 +275,54 @@ namespace graphene { namespace app {
* @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);
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;
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;
};
std::function<void(const variant &)> _on_pending_transaction;
};
class crypto_api
{
public:
class crypto_api {
public:
crypto_api();
fc::ecc::commitment_type blind( const fc::ecc::blind_factor_type& blind, uint64_t value );
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 );
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 );
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 );
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,
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 );
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);
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);
};
range_proof_info range_get_info( const std::vector<char>& proof );
};
/**
/**
* @brief
*/
class asset_api
{
public:
asset_api(graphene::app::application& app);
class asset_api {
public:
asset_api(graphene::app::application &app);
~asset_api();
/**
@ -342,14 +332,14 @@ namespace graphene { namespace app {
* @param limit Maximum limit must not exceed 100
* @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
* @param asset The specific asset id or symbol
* @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
@ -358,12 +348,13 @@ namespace graphene { namespace app {
vector<asset_holders> get_all_asset_holders() const;
uint32_t api_limit_get_asset_holders = 100;
private:
graphene::app::application& _app;
graphene::chain::database& _db;
private:
graphene::app::application &_app;
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::network_broadcast_api>;
@ -374,15 +365,14 @@ extern template class fc::api<graphene::app::asset_api>;
extern template class fc::api<graphene::debug_witness::debug_api>;
namespace graphene { namespace app {
/**
/**
* @brief The login_api class implements the bottom layer of the RPC API
*
* All other APIs must be requested from this API.
*/
class login_api
{
public:
login_api(application& a);
class login_api {
public:
login_api(application &a);
~login_api();
/**
@ -394,60 +384,65 @@ namespace graphene { namespace app {
* @note This must be called prior to requesting other APIs. Other APIs may not be accessible until the client
* 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
fc::api<block_api> block()const;
fc::api<block_api> block() const;
/// @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
fc::api<database_api> database()const;
fc::api<database_api> database() const;
/// @brief Retrieve the history API
fc::api<history_api> history()const;
fc::api<history_api> history() const;
/// @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
fc::api<crypto_api> crypto()const;
fc::api<crypto_api> crypto() const;
/// @brief Retrieve the asset API
fc::api<asset_api> asset()const;
fc::api<asset_api> asset() const;
/// @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)
fc::api<graphene::bookie::bookie_api> bookie()const;
fc::api<graphene::bookie::bookie_api> bookie() const;
/// @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.
void enable_api( const string& api_name );
private:
void enable_api(const string &api_name);
application& _app;
optional< fc::api<block_api> > _block_api;
optional< fc::api<database_api> > _database_api;
optional< fc::api<network_broadcast_api> > _network_broadcast_api;
optional< fc::api<network_node_api> > _network_node_api;
optional< fc::api<history_api> > _history_api;
optional< fc::api<crypto_api> > _crypto_api;
optional< fc::api<asset_api> > _asset_api;
optional< fc::api<graphene::debug_witness::debug_api> > _debug_api;
optional< fc::api<graphene::bookie::bookie_api> > _bookie_api;
optional< fc::api<graphene::affiliate_stats::affiliate_stats_api> > _affiliate_stats_api;
};
private:
application &_app;
optional<fc::api<block_api>> _block_api;
optional<fc::api<database_api>> _database_api;
optional<fc::api<network_broadcast_api>> _network_broadcast_api;
optional<fc::api<network_node_api>> _network_node_api;
optional<fc::api<history_api>> _history_api;
optional<fc::api<crypto_api>> _crypto_api;
optional<fc::api<asset_api>> _asset_api;
optional<fc::api<graphene::debug_witness::debug_api>> _debug_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>;
FC_REFLECT( graphene::app::network_broadcast_api::transaction_confirmation,
(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 );
// clang-format off
FC_REFLECT( graphene::app::account_asset_balance, (name)(account_id)(amount) );
FC_REFLECT( graphene::app::asset_holders, (asset_id)(count) );
FC_REFLECT(graphene::app::network_broadcast_api::transaction_confirmation,
(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,
(get_account_history)
@ -456,17 +451,17 @@ FC_API(graphene::app::history_api,
(get_fill_order_history)
(get_market_history)
(get_market_history_buckets)
(list_core_accounts)
)
(list_core_accounts))
FC_API(graphene::app::block_api,
(get_blocks)
)
(get_blocks))
FC_API(graphene::app::network_broadcast_api,
(broadcast_transaction)
(broadcast_transaction_with_callback)
(broadcast_transaction_synchronous)
(broadcast_block)
)
(broadcast_block))
FC_API(graphene::app::network_node_api,
(get_info)
(add_node)
@ -476,8 +471,8 @@ FC_API(graphene::app::network_node_api,
(set_advanced_node_parameters)
(list_pending_transactions)
(subscribe_to_pending_transactions)
(unsubscribe_from_pending_transactions)
)
(unsubscribe_from_pending_transactions))
FC_API(graphene::app::crypto_api,
(blind)
(blind_sum)
@ -485,13 +480,13 @@ FC_API(graphene::app::crypto_api,
(verify_range)
(range_proof_sign)
(verify_range_proof_rewind)
(range_get_info)
)
(range_get_info))
FC_API(graphene::app::asset_api,
(get_asset_holders)
(get_asset_holders_count)
(get_all_asset_holders)
)
(get_all_asset_holders))
FC_API(graphene::app::login_api,
(login)
(block)
@ -503,5 +498,6 @@ FC_API(graphene::app::login_api,
(asset)
(debug)
(bookie)
(affiliate_stats)
)
(affiliate_stats))
// clang-format on

View file

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

View file

@ -24,89 +24,86 @@
#pragma once
#include <graphene/app/api_access.hpp>
#include <graphene/net/node.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/net/node.hpp>
#include <boost/program_options.hpp>
namespace graphene { namespace app {
namespace detail { class application_impl; }
using std::string;
namespace detail {
class application_impl;
}
using std::string;
class abstract_plugin;
class abstract_plugin;
class application
{
public:
class application {
public:
application();
~application();
void set_program_options( boost::program_options::options_description& command_line_options,
boost::program_options::options_description& configuration_file_options )const;
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 set_program_options(boost::program_options::options_description &cli,
boost::program_options::options_description &cfg) const;
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 startup();
void shutdown();
void startup_plugins();
void shutdown_plugins();
template<typename PluginType>
std::shared_ptr<PluginType> register_plugin()
{
template <typename PluginType>
std::shared_ptr<PluginType> register_plugin() {
auto plug = std::make_shared<PluginType>();
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("Options for plugin " + plug->plugin_name()), 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);
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_desc = plug->plugin_name() + " plugin options";
_cfg_options.add_options()(header_name.c_str(), header_desc.c_str());
_cfg_options.add(plugin_cfg_options);
}
add_available_plugin( plug );
add_available_plugin(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>
std::shared_ptr<PluginType> get_plugin( const string& name ) const
{
std::shared_ptr<abstract_plugin> abs_plugin = get_plugin( name );
std::shared_ptr<PluginType> result = std::dynamic_pointer_cast<PluginType>( abs_plugin );
FC_ASSERT( result != std::shared_ptr<PluginType>() );
template <typename PluginType>
std::shared_ptr<PluginType> get_plugin(const string &name) const {
std::shared_ptr<abstract_plugin> abs_plugin = get_plugin(name);
std::shared_ptr<PluginType> result = std::dynamic_pointer_cast<PluginType>(abs_plugin);
FC_ASSERT(result != std::shared_ptr<PluginType>());
return result;
}
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);
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);
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);
bool is_finished_syncing()const;
bool is_finished_syncing() const;
/// Emitted when syncing finishes (is_finished_syncing will return true)
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;
private:
void add_available_plugin( std::shared_ptr<abstract_plugin> p );
private:
void add_available_plugin(std::shared_ptr<abstract_plugin> p);
std::shared_ptr<detail::application_impl> my;
boost::program_options::options_description _cli_options;
boost::program_options::options_description _cfg_options;
};
};
} }
}} // namespace graphene::app

View file

@ -23,12 +23,12 @@
*/
#pragma once
#include <fc/filesystem.hpp>
#include <boost/program_options.hpp>
#include <fc/filesystem.hpp>
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);
} } // graphene::app
}} // namespace graphene::app

View file

@ -32,30 +32,30 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_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/committee_member_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/operation_history_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/sport_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/sidechain_address_object.hpp>
#include <graphene/chain/son_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/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_permission_object.hpp>
#include <graphene/chain/nft_object.hpp>
#include <graphene/chain/offer_object.hpp>
#include <graphene/chain/account_role_object.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
@ -80,23 +80,20 @@ using namespace std;
class database_api_impl;
struct order
{
struct order {
double price;
double quote;
double base;
};
struct order_book
{
struct order_book {
string base;
string quote;
vector< order > bids;
vector< order > asks;
vector<order> bids;
vector<order> asks;
};
struct market_ticker
{
struct market_ticker {
string base;
string quote;
double latest;
@ -107,16 +104,14 @@ struct market_ticker
double quote_volume;
};
struct market_volume
{
struct market_volume {
string base;
string quote;
double base_volume;
double quote_volume;
};
struct market_trade
{
struct market_trade {
fc::time_point_sec date;
double price;
double amount;
@ -140,10 +135,9 @@ struct gpos_info {
* read-only; all modifications to the database must be performed via transactions. Transactions are broadcast via
* the @ref network_broadcast_api.
*/
class database_api
{
public:
database_api(graphene::chain::database& db);
class database_api {
public:
database_api(graphene::chain::database &db);
~database_api();
/////////////
@ -157,15 +151,15 @@ class database_api
*
* If any of the provided IDs does not map to an object, a null variant is returned in its position.
*/
fc::variants get_objects(const vector<object_id_type>& ids)const;
fc::variants get_objects(const vector<object_id_type> &ids) const;
///////////////////
// Subscriptions //
///////////////////
void set_subscribe_callback( std::function<void(const variant&)> cb, bool clear_filter );
void set_pending_transaction_callback( std::function<void(const variant&)> cb );
void set_block_applied_callback( std::function<void(const variant& block_id)> cb );
void set_subscribe_callback(std::function<void(const variant &)> cb, bool clear_filter);
void set_pending_transaction_callback(std::function<void(const variant &)> cb);
void set_block_applied_callback(std::function<void(const variant &block_id)> cb);
/**
* @brief Stop receiving any notifications
*
@ -182,22 +176,21 @@ class database_api
* @param block_num Height of the block whose header should be returned
* @return header of the referenced block, or null if no matching block was found
*/
optional<block_header> get_block_header(uint32_t block_num)const;
optional<block_header> get_block_header(uint32_t block_num) const;
/**
* @brief Retrieve multiple block header by block numbers
* @param block_num vector containing heights of the block whose header should be returned
* @return array of headers of the referenced blocks, or null if no matching block was found
*/
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
* @param block_num Height of the block to be returned
* @return the referenced block, or null if no matching block was found
*/
optional<signed_block> get_block(uint32_t block_num)const;
optional<signed_block> get_block(uint32_t block_num) const;
/**
* @brief Retrieve a list of signed blocks
@ -205,19 +198,19 @@ class database_api
* @param block_num_to end
* @return list of referenced blocks
*/
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;
/**
* @brief used to fetch an individual transaction.
*/
processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const;
/**
* If the transaction has not expired, this method will return the transaction for the given ID or
* it will return NULL if it is not known. Just because it is not known does not mean it wasn't
* included in the blockchain.
*/
optional<signed_transaction> get_recent_transaction_by_id( const transaction_id_type& id )const;
optional<signed_transaction> get_recent_transaction_by_id(const transaction_id_type &id) const;
/////////////
// Globals //
@ -226,33 +219,33 @@ class database_api
/**
* @brief Retrieve the @ref chain_property_object associated with the chain
*/
chain_property_object get_chain_properties()const;
chain_property_object get_chain_properties() const;
/**
* @brief Retrieve the current @ref global_property_object
*/
global_property_object get_global_properties()const;
global_property_object get_global_properties() const;
/**
* @brief Retrieve compile-time constants
*/
fc::variant_object get_config()const;
fc::variant_object get_config() const;
/**
* @brief Get the chain ID
*/
chain_id_type get_chain_id()const;
chain_id_type get_chain_id() const;
/**
* @brief Retrieve the current @ref dynamic_global_property_object
*/
dynamic_global_property_object get_dynamic_global_properties()const;
dynamic_global_property_object get_dynamic_global_properties() const;
//////////
// Keys //
//////////
vector<vector<account_id_type>> get_key_references( vector<public_key_type> key )const;
vector<vector<account_id_type>> get_key_references(vector<public_key_type> key) const;
/**
* Determine whether a textual representation of a public key
@ -273,7 +266,7 @@ class database_api
* @return Account ID
*
*/
account_id_type get_account_id_from_string(const std::string& name_or_id)const;
account_id_type get_account_id_from_string(const std::string &name_or_id) const;
/**
* @brief Get a list of accounts by ID or Name
@ -282,7 +275,7 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<account_object>> get_accounts(const vector<std::string>& account_names_or_ids)const;
vector<optional<account_object>> get_accounts(const vector<std::string> &account_names_or_ids) const;
/**
* @brief Fetch all objects relevant to the specified accounts and subscribe to updates
@ -295,14 +288,14 @@ class database_api
* ignored. All other accounts will be retrieved and subscribed.
*
*/
std::map<string,full_account> get_full_accounts( const vector<string>& names_or_ids, bool subscribe );
std::map<string, full_account> get_full_accounts(const vector<string> &names_or_ids, bool subscribe);
optional<account_object> get_account_by_name( string name )const;
optional<account_object> get_account_by_name(string name) const;
/**
* @return all accounts that referr to the key or account id in their owner or active authorities.
*/
vector<account_id_type> get_account_references( const std::string account_name_or_id )const;
vector<account_id_type> get_account_references(const std::string account_name_or_id) const;
/**
* @brief Get a list of accounts by name
@ -311,7 +304,7 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
vector<optional<account_object>> lookup_account_names(const vector<string> &account_names) const;
/**
* @brief Get names and IDs for registered accounts
@ -319,7 +312,7 @@ class database_api
* @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of account names to corresponding IDs
*/
map<string,account_id_type> lookup_accounts(const string& lower_bound_name, uint32_t limit)const;
map<string, account_id_type> lookup_accounts(const string &lower_bound_name, uint32_t limit) const;
//////////////
// Balances //
@ -331,23 +324,23 @@ class database_api
* @param assets IDs of the assets to get balances of; if empty, get all assets account has a balance in
* @return Balances of the account
*/
vector<asset> get_account_balances( const std::string& account_name_or_id,
const flat_set<asset_id_type>& assets )const;
vector<asset> get_account_balances(const std::string &account_name_or_id,
const flat_set<asset_id_type> &assets) const;
/// Semantically equivalent to @ref get_account_balances, but takes a name instead of an ID.
vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
vector<asset> get_named_account_balances(const std::string &name, const flat_set<asset_id_type> &assets) const;
/** @return all unclaimed balance objects for a set of addresses */
vector<balance_object> get_balance_objects( const vector<address>& addrs )const;
vector<balance_object> get_balance_objects(const vector<address> &addrs) const;
vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
vector<asset> get_vested_balances(const vector<balance_id_type> &objs) const;
vector<vesting_balance_object> get_vesting_balances( const std::string account_id_or_name )const;
vector<vesting_balance_object> get_vesting_balances(const std::string account_id_or_name) const;
/**
* @brief Get the total number of accounts registered with the blockchain
*/
uint64_t get_account_count()const;
uint64_t get_account_count() const;
////////////
// Assets //
@ -358,7 +351,7 @@ class database_api
* @param symbol_or_id symbol name or ID of the asset
* @return asset ID
*/
asset_id_type get_asset_id_from_string(const std::string& symbol_or_id) const;
asset_id_type get_asset_id_from_string(const std::string &symbol_or_id) const;
/**
* @brief Get a list of assets by ID
@ -367,7 +360,7 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<asset_object>> get_assets(const vector<std::string>& asset_symbols_or_ids)const;
vector<optional<asset_object>> get_assets(const vector<std::string> &asset_symbols_or_ids) const;
/**
* @brief Get assets alphabetically by symbol name
@ -375,7 +368,7 @@ class database_api
* @param limit Maximum number of assets to fetch (must not exceed 100)
* @return The assets found
*/
vector<asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const;
vector<asset_object> list_assets(const string &lower_bound_symbol, uint32_t limit) const;
/**
* @brief Get a list of assets by symbol
@ -384,13 +377,13 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<asset_object>> lookup_asset_symbols(const vector<string>& symbols_or_ids)const;
vector<optional<asset_object>> lookup_asset_symbols(const vector<string> &symbols_or_ids) const;
/**
* @brief Get assets count
* @return The assets count
*/
uint64_t get_asset_count()const;
uint64_t get_asset_count() const;
////////////////////
// Lottery Assets //
@ -399,20 +392,19 @@ class database_api
* @brief Get a list of lottery assets
* @return The lottery assets between start and stop ids
*/
vector<asset_object> get_lotteries( asset_id_type stop = asset_id_type(),
vector<asset_object> get_lotteries(asset_id_type stop = asset_id_type(),
unsigned limit = 100,
asset_id_type start = asset_id_type() )const;
vector<asset_object> get_account_lotteries( account_id_type issuer,
asset_id_type start = asset_id_type()) const;
vector<asset_object> get_account_lotteries(account_id_type issuer,
asset_id_type stop,
unsigned limit,
asset_id_type start )const;
sweeps_vesting_balance_object get_sweeps_vesting_balance_object( account_id_type account )const;
asset get_sweeps_vesting_balance_available_for_claim( account_id_type account )const;
asset_id_type start) const;
sweeps_vesting_balance_object get_sweeps_vesting_balance_object(account_id_type account) const;
asset get_sweeps_vesting_balance_available_for_claim(account_id_type account) const;
/**
* @brief Get balance of lottery assets
*/
asset get_lottery_balance( asset_id_type lottery_id ) const;
asset get_lottery_balance(asset_id_type lottery_id) const;
/////////////////////
// Peerplays //
@ -469,7 +461,7 @@ class database_api
* @param limit Maximum number of orders to retrieve
* @return The limit orders, ordered from least price to greatest
*/
vector<limit_order_object> get_limit_orders(const std::string& a, const std::string& b, uint32_t limit)const;
vector<limit_order_object> get_limit_orders(const std::string &a, const std::string &b, uint32_t limit) const;
/**
* @brief Get call orders in a given asset
@ -477,7 +469,7 @@ class database_api
* @param limit Maximum number of orders to retrieve
* @return The call orders, ordered from earliest to be called to latest
*/
vector<call_order_object> get_call_orders(const std::string& a, uint32_t limit)const;
vector<call_order_object> get_call_orders(const std::string &a, uint32_t limit) const;
/**
* @brief Get forced settlement orders in a given asset
@ -485,12 +477,12 @@ class database_api
* @param limit Maximum number of orders to retrieve
* @return The settle orders, ordered from earliest settlement date to latest
*/
vector<force_settlement_object> get_settle_orders(const std::string& a, uint32_t limit)const;
vector<force_settlement_object> get_settle_orders(const std::string &a, uint32_t limit) const;
/**
* @return all open margin positions for a given account id.
*/
vector<call_order_object> get_margin_positions( const std::string account_id_or_name )const;
vector<call_order_object> get_margin_positions(const std::string account_id_or_name) const;
/**
* @brief Request notification when the active orders in the market between two assets changes
@ -501,15 +493,15 @@ class database_api
* Callback will be passed a variant containing a vector<pair<operation, operation_result>>. The vector will
* contain, in order, the operations which changed the market, and their results.
*/
void subscribe_to_market(std::function<void(const variant&)> callback,
const std::string& a, const std::string& b);
void subscribe_to_market(std::function<void(const variant &)> callback,
const std::string &a, const std::string &b);
/**
* @brief Unsubscribe from updates to a given market
* @param a First asset ID or name
* @param b Second asset ID or name
*/
void unsubscribe_from_market( const std::string& a, const std::string& b );
void unsubscribe_from_market(const std::string &a, const std::string &b);
/**
* @brief Returns the ticker for the market assetA:assetB
@ -517,7 +509,7 @@ class database_api
* @param b String name of the second asset
* @return The market ticker for the past 24 hours.
*/
market_ticker get_ticker( const string& base, const string& quote )const;
market_ticker get_ticker(const string &base, const string &quote) const;
/**
* @brief Returns the 24 hour volume for the market assetA:assetB
@ -525,7 +517,7 @@ class database_api
* @param b String name of the second asset
* @return The market volume over the past 24 hours
*/
market_volume get_24_volume( const string& base, const string& quote )const;
market_volume get_24_volume(const string &base, const string &quote) const;
/**
* @brief Returns the order book for the market base:quote
@ -534,7 +526,7 @@ class database_api
* @param depth of the order book. Up to depth of each asks and bids, capped at 50. Prioritizes most moderate of each
* @return Order book of the market
*/
order_book get_order_book( const string& base, const string& quote, unsigned limit = 50 )const;
order_book get_order_book(const string &base, const string &quote, unsigned limit = 50) const;
/**
* @brief Returns recent trades for the market assetA:assetB
@ -546,9 +538,7 @@ class database_api
* @param start Start time as a UNIX timestamp
* @return Recent transactions in the market
*/
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 //
@ -561,14 +551,14 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const;
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type> &witness_ids) const;
/**
* @brief Get the witness owned by a given account
* @param account The ID of the account whose witness should be retrieved
* @return The witness object, or null if the account does not have a witness
*/
fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id)const;
fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id) const;
/**
* @brief Get names and IDs for registered witnesses
@ -576,12 +566,12 @@ class database_api
* @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of witness names to corresponding IDs
*/
map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;
map<string, witness_id_type> lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const;
/**
* @brief Get the total number of witnesses registered with the blockchain
*/
uint64_t get_witness_count()const;
uint64_t get_witness_count() const;
///////////////////////
// Committee members //
@ -594,14 +584,14 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type>& committee_member_ids)const;
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const;
/**
* @brief Get the committee_member owned by a given account
* @param account_id_or_name The ID or name of the account whose committee_member should be retrieved
* @return The committee_member object, or null if the account does not have a committee_member
*/
fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name)const;
fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name) const;
/**
* @brief Get names and IDs for registered committee_members
@ -609,7 +599,7 @@ class database_api
* @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of committee_member names to corresponding IDs
*/
map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const;
map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const;
/////////////////
// SON members //
@ -622,14 +612,14 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<son_object>> get_sons(const vector<son_id_type>& son_ids)const;
vector<optional<son_object>> get_sons(const vector<son_id_type> &son_ids) const;
/**
* @brief Get the SON owned by a given account
* @param account The ID of the account whose SON should be retrieved
* @return The SON object, or null if the account does not have a SON
*/
fc::optional<son_object> get_son_by_account(account_id_type account)const;
fc::optional<son_object> get_son_by_account(account_id_type account) const;
/**
* @brief Get names and IDs for registered SONs
@ -637,12 +627,12 @@ class database_api
* @param limit Maximum number of results to return -- must not exceed 1000
* @return Map of SON names to corresponding IDs
*/
map<string, son_id_type> lookup_son_accounts(const string& lower_bound_name, uint32_t limit)const;
map<string, son_id_type> lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const;
/**
* @brief Get the total number of SONs registered with the blockchain
*/
uint64_t get_son_count()const;
uint64_t get_son_count() const;
/////////////////////////
// SON Wallets //
@ -679,21 +669,21 @@ class database_api
*
* This function has semantics identical to @ref get_objects
*/
vector<optional<sidechain_address_object>> get_sidechain_addresses(const vector<sidechain_address_id_type>& sidechain_address_ids)const;
vector<optional<sidechain_address_object>> get_sidechain_addresses(const vector<sidechain_address_id_type> &sidechain_address_ids) const;
/**
* @brief Get the sidechain addresses for a given account
* @param account The ID of the account whose sidechain addresses should be retrieved
* @return The sidechain addresses objects, or null if the account does not have a sidechain addresses
*/
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(account_id_type account)const;
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(account_id_type account) const;
/**
* @brief Get the sidechain addresses for a given sidechain
* @param sidechain Sidechain for which addresses should be retrieved
* @return The sidechain addresses objects, or null if the sidechain does not have any addresses
*/
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(sidechain_type sidechain)const;
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(sidechain_type sidechain) const;
/**
* @brief Get the sidechain addresses for a given account and sidechain
@ -701,12 +691,12 @@ class database_api
* @param sidechain Sidechain for which address should be retrieved
* @return The sidechain addresses objects, or null if the account does not have a sidechain addresses for a given sidechain
*/
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain)const;
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, sidechain_type sidechain) const;
/**
* @brief Get the total number of sidechain addresses registered with the blockchain
*/
uint64_t get_sidechain_addresses_count()const;
uint64_t get_sidechain_addresses_count() const;
/// WORKERS
@ -715,8 +705,7 @@ class database_api
* @param account_id_or_name The ID or name of the account whose worker should be retrieved
* @return The worker object or null if the account does not have a worker
*/
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 //
@ -730,49 +719,49 @@ class database_api
* The results will be in the same order as the votes. Null will be returned for
* any vote ids that are not found.
*/
vector<variant> lookup_vote_ids( const vector<vote_id_type>& votes )const;
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
////////////////////////////
// Authority / validation //
////////////////////////////
/// @brief Get a hexdump of the serialized binary form of a transaction
std::string get_transaction_hex(const signed_transaction& trx)const;
std::string get_transaction_hex(const signed_transaction &trx) const;
/**
* This API will take a partially signed transaction and a set of public keys that the owner has the ability to sign for
* and return the minimal subset of public keys that should add signatures to the transaction.
*/
set<public_key_type> get_required_signatures( const signed_transaction& trx, const flat_set<public_key_type>& available_keys )const;
set<public_key_type> get_required_signatures(const signed_transaction &trx, const flat_set<public_key_type> &available_keys) const;
/**
* This method will return the set of all public keys that could possibly sign for a given transaction. This call can
* be used by wallets to filter their set of public keys to just the relevant subset prior to calling @ref get_required_signatures
* to get the minimum subset.
*/
set<public_key_type> get_potential_signatures( const signed_transaction& trx )const;
set<address> get_potential_address_signatures( const signed_transaction& trx )const;
set<public_key_type> get_potential_signatures(const signed_transaction &trx) const;
set<address> get_potential_address_signatures(const signed_transaction &trx) const;
/**
* @return true of the @ref trx has all of the required signatures, otherwise throws an exception
*/
bool verify_authority( const signed_transaction& trx )const;
bool verify_authority(const signed_transaction &trx) const;
/**
* @return true if the signers have enough authority to authorize an account
*/
bool verify_account_authority( const string& name_or_id, const flat_set<public_key_type>& signers )const;
bool verify_account_authority(const string &name_or_id, const flat_set<public_key_type> &signers) const;
/**
* Validates a transaction against the current state without broadcasting it on the network.
*/
processed_transaction validate_transaction( const signed_transaction& trx )const;
processed_transaction validate_transaction(const signed_transaction &trx) const;
/**
* For each operation calculate the required fee in the specified asset type. If the asset type does
* not have a valid core_exchange_rate
*/
vector< fc::variant > get_required_fees( const vector<operation>& ops, const std::string& asset_id_or_symbol )const;
vector<fc::variant> get_required_fees(const vector<operation> &ops, const std::string &asset_id_or_symbol) const;
///////////////////////////
// Proposed transactions //
@ -781,7 +770,7 @@ class database_api
/**
* @return the set of proposed transactions relevant to the specified account id.
*/
vector<proposal_object> get_proposed_transactions( const std::string account_id_or_name )const;
vector<proposal_object> get_proposed_transactions(const std::string account_id_or_name) const;
//////////////////////
// Blinded balances //
@ -790,7 +779,7 @@ class database_api
/**
* @return the set of blinded balance objects by commitment ID
*/
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
vector<blinded_balance_object> get_blinded_balances(const flat_set<commitment_type> &commitments) const;
/////////////////
// Tournaments //
@ -829,10 +818,10 @@ class database_api
* @return account and custom permissions/account-authorities info
*/
vector<custom_permission_object> get_custom_permissions(const account_id_type account) const;
fc::optional<custom_permission_object> get_custom_permission_by_name(const account_id_type account, const string& permission_name) const;
fc::optional<custom_permission_object> get_custom_permission_by_name(const account_id_type account, const string &permission_name) const;
vector<custom_account_authority_object> get_custom_account_authorities(const account_id_type account) const;
vector<custom_account_authority_object> get_custom_account_authorities_by_permission_id(const custom_permission_id_type permission_id) const;
vector<custom_account_authority_object> get_custom_account_authorities_by_permission_name(const account_id_type account, const string& permission_name) const;
vector<custom_account_authority_object> get_custom_account_authorities_by_permission_name(const account_id_type account, const string &permission_name) const;
vector<authority> get_active_custom_account_authorities_by_operation(const account_id_type account, int operation_type) const;
/////////
@ -943,21 +932,22 @@ class database_api
//////////////////
vector<account_role_object> get_account_roles_by_owner(account_id_type owner) const;
private:
std::shared_ptr< database_api_impl > my;
private:
std::shared_ptr<database_api_impl> my;
};
} }
}} // namespace graphene::app
extern template class fc::api<graphene::app::database_api>;
FC_REFLECT( graphene::app::order, (price)(quote)(base) );
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_volume, (base)(quote)(base_volume)(quote_volume) );
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) );
// clang-format off
FC_REFLECT(graphene::app::order, (price)(quote)(base));
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_volume, (base)(quote)(base_volume)(quote_volume));
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_API(graphene::app::database_api,
// Objects
@ -1136,3 +1126,5 @@ FC_API(graphene::app::database_api,
// Account Roles
(get_account_roles_by_owner)
)
// clang-format on

View file

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

View file

@ -30,12 +30,12 @@
namespace graphene { namespace app {
class abstract_plugin
{
public:
virtual ~abstract_plugin(){}
virtual std::string plugin_name()const = 0;
virtual std::string plugin_description()const = 0;
class abstract_plugin {
public:
virtual ~abstract_plugin() {
}
virtual std::string plugin_name() const = 0;
virtual std::string plugin_description() const = 0;
/**
* @brief Perform early startup routines and register plugin indexes, callbacks, etc.
@ -49,7 +49,7 @@ class abstract_plugin
*
* @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
@ -71,7 +71,7 @@ class abstract_plugin
*
* 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.
@ -84,64 +84,65 @@ class abstract_plugin
* If a plugin does not need these options, it
* may simply provide an empty implementation of this method.
*/
virtual void plugin_set_program_options(
boost::program_options::options_description& command_line_options,
boost::program_options::options_description& config_file_options
) = 0;
virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options,
boost::program_options::options_description &config_file_options) = 0;
};
/**
* Provides basic default implementations of abstract_plugin functions.
*/
class plugin : public abstract_plugin
{
public:
class plugin : public abstract_plugin {
public:
plugin();
virtual ~plugin() override;
virtual std::string plugin_name()const override;
virtual std::string plugin_description()const override;
virtual void plugin_initialize( const boost::program_options::variables_map& options ) override;
virtual std::string plugin_name() const override;
virtual std::string plugin_description() const override;
virtual void plugin_initialize(const boost::program_options::variables_map &options) override;
virtual void plugin_startup() override;
virtual void plugin_shutdown() override;
virtual void plugin_set_app( application* app ) override;
virtual void plugin_set_program_options(
boost::program_options::options_description& command_line_options,
boost::program_options::options_description& config_file_options
) override;
virtual void plugin_set_app(application *app) override;
virtual void plugin_set_program_options(boost::program_options::options_description &command_line_options,
boost::program_options::options_description &config_file_options) override;
chain::database& database() { return *app().chain_database(); }
application& app()const { assert(_app); return *_app; }
protected:
net::node& p2p_node() { return *app().p2p_node(); }
chain::database &database() {
return *app().chain_database();
}
application &app() const {
assert(_app);
return *_app;
}
private:
application* _app = nullptr;
protected:
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
/// @{
template<typename T>
T dejsonify(const string& s, uint32_t max_depth)
{
template <typename T>
T dejsonify(const string &s, uint32_t max_depth) {
return fc::json::from_string(s).as<T>(max_depth);
}
namespace impl {
template<typename T>
T dejsonify( const string& s )
{
return graphene::app::dejsonify<T>( s, GRAPHENE_MAX_NESTED_OBJECTS );
}
template <typename T>
T dejsonify(const string &s) {
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 LOAD_VALUE_SET(options, name, container, type) \
if( options.count(name) ) { \
const std::vector<std::string>& ops = options[name].as<std::vector<std::string>>(); \
if (options.count(name)) { \
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>); \
}
}
/// @}
} } //graphene::app
}} // namespace graphene::app

View file

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

View file

@ -1,3 +1,7 @@
#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

View file

@ -1,4 +1,8 @@
// added delete sport and delete event group operations
#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

View file

@ -1,4 +1,8 @@
// #357 Disallow publishing certain malformed price feeds
#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

View file

@ -1,4 +1,8 @@
// #359 Allow digits in asset name
#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

View file

@ -1,4 +1,8 @@
// #385 October 23 enforce PARENT.CHILD and allow short names
#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

View file

@ -1,4 +1,8 @@
// #409 Allow creation of sub-assets
#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

View file

@ -1,4 +1,8 @@
// #413 Add operation to claim asset fees
#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

View file

@ -1,4 +1,8 @@
// #415 Default accept policy for asset with no whitelist authorities
#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

View file

@ -1,4 +1,8 @@
// #416 enforce_white_list is inconsistently applied
#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

View file

@ -1,4 +1,8 @@
// #419 Account can pay fees in blacklisted asset
#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

View file

@ -1,4 +1,8 @@
// #436 Prevent margin call from being triggered unless feed < call price
#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

View file

@ -1,4 +1,8 @@
// #445 Refund create order fees on cancel
#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

View file

@ -1,4 +1,8 @@
// #453 Hardfork to retroactively correct referral percentages
#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

View file

@ -1,4 +1,8 @@
// #480 Fix non-BTS MIA core_exchange_rate check
#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

View file

@ -1,4 +1,8 @@
// #483 Operation history numbering change
#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

View file

@ -1,4 +1,7 @@
// 5050_1 HARDFORK Wednesday, 15 April 2020 20:00:00 GMT
#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

View file

@ -1,4 +1,8 @@
// #516 Special authorities
#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

View file

@ -1,4 +1,8 @@
// #533 Improve vote counting implementation
#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

View file

@ -1,4 +1,8 @@
// #538 Buyback accounts
#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

View file

@ -1,4 +1,8 @@
// #555 Buyback accounts
#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

View file

@ -1,4 +1,8 @@
// #563 Stealth fee routing
#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

View file

@ -1,4 +1,8 @@
// #572 Allow asset to update permission flags when no supply exists
#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

View file

@ -1,4 +1,8 @@
// #599 Unpacking of extension is incorrect
#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

View file

@ -1,4 +1,8 @@
// #607 Disable negative voting on workers
#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

View file

@ -1,4 +1,8 @@
// #613 Deprecate annual membership
#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

View file

@ -1,4 +1,8 @@
// #615 Fix price feed expiration check, so websocket server will never spam too much data
#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

View file

@ -1,4 +1,8 @@
// Placeholder HF for affiliate reward system
#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

View file

@ -1,4 +1,8 @@
// bitshares-core #429 rounding issue when creating assets
#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

View file

@ -1,6 +1,10 @@
// #210 Check authorities on custom_operation
#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.
#define MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time) (chain_time <= HARDFORK_CORE_210_TIME)
#endif

View file

@ -1,4 +1,7 @@
// GPOS HARDFORK Monday, 6 January 2020 01:00:00 GMT
#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

View file

@ -1,4 +1,7 @@
// NFT HARDFORK Sat, 15-Aug-20 00:00:00 UTC
#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

View file

@ -1,4 +1,7 @@
// SON HARDFORK Wednesday, October 28, 2020 0:00:00 GMT
#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

View file

@ -1,4 +1,7 @@
// SON2 HARDFORK Saturday, July 31, 2021 00:00:00 GMT
#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

View file

@ -1,4 +1,7 @@
// Wednesday, March 31, 2021 0:00:00
#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

View file

@ -1,3 +1,7 @@
#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

View file

@ -23,8 +23,13 @@
*/
#pragma once
#ifdef BUILD_PEERPLAYS_TESTNET
#define GRAPHENE_SYMBOL "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_MAX_ACCOUNT_NAME_LENGTH 63