Merge branch 'rock-paper-scissors-ro' into rock-paper-scissors

Conflicts:
	programs/witness_node/main.cpp
This commit is contained in:
Roman Olearski 2017-06-09 12:17:26 +02:00
commit eb4c8f75d1
10 changed files with 253 additions and 1 deletions

View file

@ -12,7 +12,7 @@ add_library( graphene_app
)
# need to link graphene_debug_witness because plugins aren't sufficiently isolated #246
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness )
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness )
target_include_directories( graphene_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )

View file

@ -458,6 +458,13 @@ namespace graphene { namespace app {
return result;
}
vector<account_balance_object> history_api::list_core_accounts()const
{
auto list = _app.get_plugin<accounts_list_plugin>( "accounts_list" );
FC_ASSERT( list );
return list->list_accounts();
}
flat_set<uint32_t> history_api::get_market_history_buckets()const
{
auto hist = _app.get_plugin<market_history_plugin>( "market_history" );
@ -490,6 +497,7 @@ namespace graphene { namespace app {
}
return result;
} FC_CAPTURE_AND_RETHROW( (a)(b)(bucket_seconds)(start)(end) ) }
crypto_api::crypto_api(){};

View file

@ -29,6 +29,7 @@
#include <graphene/chain/protocol/confidential.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
#include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/debug_witness/debug_api.hpp>
@ -49,6 +50,7 @@
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;
@ -113,6 +115,7 @@ namespace graphene { namespace app {
vector<order_history_object> get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const;
vector<bucket_object> get_market_history( asset_id_type a, asset_id_type 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;
private:
application& _app;
@ -316,6 +319,7 @@ FC_API(graphene::app::history_api,
(get_fill_order_history)
(get_market_history)
(get_market_history_buckets)
(list_core_accounts)
)
FC_API(graphene::app::network_broadcast_api,
(broadcast_transaction)

View file

@ -1,5 +1,6 @@
add_subdirectory( witness )
add_subdirectory( account_history )
add_subdirectory( accounts_list )
add_subdirectory( market_history )
add_subdirectory( delayed_node )
add_subdirectory( generate_genesis )

View file

@ -0,0 +1,21 @@
file(GLOB HEADERS "include/graphene/accouns_list/*.hpp")
add_library( graphene_accounts_list
accounts_list_plugin.cpp
)
target_link_libraries( graphene_accounts_list graphene_chain graphene_app )
target_include_directories( graphene_accounts_list
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
if(MSVC)
set_source_files_properties( accounts_list_plugin.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
endif(MSVC)
install( TARGETS
graphene_accounts_list
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/app/impacted.hpp>
#include <graphene/chain/account_evaluator.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/config.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>
#include <fc/smart_ref_impl.hpp>
#include <fc/thread/thread.hpp>
namespace graphene { namespace accounts_list {
namespace detail
{
class accounts_list_plugin_impl
{
public:
accounts_list_plugin_impl(accounts_list_plugin& _plugin)
: _self( _plugin )
{ }
virtual ~accounts_list_plugin_impl();
/**
*/
void list_accounts();
graphene::chain::database& database()
{
return _self.database();
}
accounts_list_plugin& _self;
vector<account_balance_object> _listed_balances;
};
accounts_list_plugin_impl::~accounts_list_plugin_impl()
{
return;
}
void accounts_list_plugin_impl::list_accounts()
{
graphene::chain::database& db = database();
_listed_balances.clear();
auto& balance_index = db.get_index_type<graphene::chain::account_balance_index>().indices().get<graphene::chain::by_asset_balance>();
for (auto balance_iter = balance_index.begin();
balance_iter != balance_index.end() &&
balance_iter->asset_type == graphene::chain::asset_id_type() &&
balance_iter->balance > 0; ++balance_iter)
{
//idump((balance_iter->owner(db) .name)(*balance_iter));
_listed_balances.emplace_back(*balance_iter);
}
}
} // end namespace detail
accounts_list_plugin::accounts_list_plugin() :
my( new detail::accounts_list_plugin_impl(*this) )
{
}
accounts_list_plugin::~accounts_list_plugin()
{
}
std::string accounts_list_plugin::plugin_name()const
{
return "accounts_list";
}
void accounts_list_plugin::plugin_set_program_options(
boost::program_options::options_description& /*cli*/,
boost::program_options::options_description& /*cfg*/
)
{
// cli.add_options()
// ("list-account", boost::program_options::value<std::vector<std::string>>()->composing()->multitoken(), "Account ID to list (may specify multiple times)")
// ;
// cfg.add(cli);
}
void accounts_list_plugin::plugin_initialize(const boost::program_options::variables_map& /*options*/)
{
//ilog("accounts list plugin: plugin_initialize()");
list_accounts();
}
void accounts_list_plugin::plugin_startup()
{
//ilog("accounts list plugin: plugin_startup()");
}
vector<account_balance_object> accounts_list_plugin::list_accounts() const
{
ilog("accounts list plugin: list_accounts()");
my->list_accounts();
//idump((my->_listed_balances));
return my->_listed_balances;
}
} }

View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <graphene/app/plugin.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/account_object.hpp>
#include <fc/thread/future.hpp>
namespace graphene { namespace accounts_list {
using namespace chain;
namespace detail
{
class accounts_list_plugin_impl;
}
class accounts_list_plugin : public graphene::app::plugin
{
public:
accounts_list_plugin();
virtual ~accounts_list_plugin();
std::string plugin_name()const override;
virtual void plugin_set_program_options(
boost::program_options::options_description& cli,
boost::program_options::options_description& cfg) override;
virtual void plugin_initialize(const boost::program_options::variables_map& options) override;
virtual void plugin_startup() override;
vector<account_balance_object>list_accounts()const;
friend class detail::accounts_list_plugin_impl;
std::unique_ptr<detail::accounts_list_plugin_impl> my;
};
} } //graphene::accounts_list

View file

@ -340,6 +340,7 @@ class wallet_api
*/
vector<operation_detail> get_account_history(string name, int limit)const;
vector<account_balance_object> list_core_accounts()const;
vector<bucket_object> get_market_history(string symbol, string symbol2, uint32_t bucket)const;
vector<limit_order_object> get_limit_orders(string a, string b, uint32_t limit)const;
@ -1740,6 +1741,7 @@ FC_API( graphene::wallet::wallet_api,
(get_block)
(get_account_count)
(get_account_history)
(list_core_accounts)
(get_market_history)
(get_global_properties)
(get_dynamic_global_properties)

View file

@ -2461,6 +2461,21 @@ public:
return ss.str();
};
m["list_core_accounts"] = [this](variant result, const fc::variants& a)
{
std::stringstream ss;
auto balances = result.as<vector<account_balance_object>>();
for (const account_balance_object& balance: balances)
{
const account_object& account = get_account(balance.owner);
//ss << account.name << " " << std::string(balance.id) << " " << balance.balance.value << "\n";
ss << account.name << " " << std::string(balance.id) << " " << get_asset(balance.asset_type).amount_to_pretty_string(balance.balance) << "\n";
}
return ss.str();
};
m["get_blind_balances"] = [this](variant result, const fc::variants& a)
{
auto r = result.as<vector<asset>>();
@ -3386,6 +3401,10 @@ vector<operation_detail> wallet_api::get_account_history(string name, int limit)
return result;
}
vector<account_balance_object> wallet_api::list_core_accounts()const
{
return my->_remote_hist->list_core_accounts();
}
vector<bucket_object> wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket )const
{

View file

@ -25,6 +25,7 @@
#include <graphene/witness/witness.hpp>
#include <graphene/account_history/account_history_plugin.hpp>
#include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
//#include <graphene/generate_genesis/generate_genesis_plugin.hpp>
//#include <graphene/generate_uia_sharedrop_genesis/generate_uia_sharedrop_genesis.hpp>
@ -78,6 +79,7 @@ int main(int argc, char** argv) {
auto market_history_plug = node->register_plugin<market_history::market_history_plugin>();
//auto generate_genesis_plug = node->register_plugin<generate_genesis_plugin::generate_genesis_plugin>();
//auto generate_uia_sharedrop_genesis_plug = node->register_plugin<generate_uia_sharedrop_genesis::generate_uia_sharedrop_genesis_plugin>();
auto list_plug = node->register_plugin<accounts_list::accounts_list_plugin>();
try
{