Skip to content

Commit

Permalink
Merge pull request #1838 from bitshares/develop
Browse files Browse the repository at this point in the history
Merge develop branch into hardfork branch
  • Loading branch information
abitmore authored Jul 3, 2019
2 parents 34e9eaa + 725dff1 commit d98c38a
Show file tree
Hide file tree
Showing 257 changed files with 6,768 additions and 3,516 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set the default behavior of genesis.json, in case core.autocrlf is set incorrectly
genesis.json eol=lf
17 changes: 7 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ script:
- ccache -s
- programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
- programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
- programs/build_helpers/buildstep make.cli_wallet 1600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet"
- programs/build_helpers/buildstep make.witness_node 300 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node"
- programs/build_helpers/buildstep make.serializer 45 "programs/build_helpers/make_with_sonar bw-output -j 2 js_operation_serializer"
- programs/build_helpers/buildstep make.get_dev_key 10 "programs/build_helpers/make_with_sonar bw-output -j 2 get_dev_key"
- programs/build_helpers/buildstep make.chain_test 900 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test"
- programs/build_helpers/buildstep make.cli_test 200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test"
- programs/build_helpers/buildstep make.perf_test 120 "programs/build_helpers/make_with_sonar bw-output -j 2 performance_test"
- programs/build_helpers/buildstep make.cli_wallet 2200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet witness_node js_operation_serializer get_dev_key network_mapper"
- programs/build_helpers/buildstep make.chain_test 1000 "make -j 2 chain_test"
- programs/build_helpers/buildstep make.cli_test 200 "make -j 2 cli_test"
- programs/build_helpers/buildstep make.perf_test 120 "make -j 2 performance_test"
- set -o pipefail
- programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test"
- programs/build_helpers/buildstep run.cli_test 30 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test"
- programs/build_helpers/buildstep prepare.sonar 20 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null'
- programs/build_helpers/buildstep run.sonar 400 "which sonar-scanner && sonar-scanner || true"
- programs/build_helpers/buildstep run.cli_test 60 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test"
- 'programs/build_helpers/buildstep prepare.sonar 20 "find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o \"\$d\" \"\${d/CMakeFiles*.dir//}\"/*.cpp; done >/dev/null; programs/build_helpers/set_sonar_branch sonar-project.properties" || true'
- 'programs/build_helpers/buildstep run.sonar 1200 "which sonar-scanner && sonar-scanner" || true'
- programs/build_helpers/buildstep end 0
- ccache -s
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defines BitShares library target.
project( BitShares )
cmake_minimum_required( VERSION 2.8.12 )
cmake_minimum_required( VERSION 3.1 )

set( BLOCKCHAIN_NAME "BitShares" )

Expand All @@ -9,6 +9,10 @@ set( GUI_CLIENT_EXECUTABLE_NAME BitShares )
set( CUSTOM_URL_SCHEME "gcs" )
set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" )

set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )

# http://stackoverflow.com/a/18369825
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
Expand All @@ -23,7 +27,7 @@ endif()
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/genesis.json" )
set(GRAPHENE_EGENESIS_JSON "${CMAKE_CURRENT_SOURCE_DIR}/libraries/egenesis/genesis.json" )

#set (ENABLE_INSTALLER 1)
#set (USE_PCH 1)
Expand Down Expand Up @@ -51,6 +55,7 @@ LIST(APPEND BOOST_COMPONENTS thread
chrono
unit_test_framework
context)
# boost::endian is also required, but FindBoost can't handle header-only libs
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )

IF( WIN32 )
Expand Down Expand Up @@ -80,6 +85,7 @@ if( WIN32 )
set(CRYPTO_LIB)

if( MSVC )
add_definitions(-DWIN32_LEAN_AND_MEAN)
#looks like this flag can have different default on some machines.
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
Expand Down Expand Up @@ -108,11 +114,11 @@ else( WIN32 ) # Apple AND Linux
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring BitShares on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring BitShares on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
if(USE_PROFILER)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
endif( USE_PROFILER )
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Bitshares-Core"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "2.0.180823"
PROJECT_NUMBER = "3.0.1"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ We recommend building on Ubuntu 16.04 LTS (64-bit)
git submodule sync --recursive
git submodule update --init --recursive

**NOTE:** Versions of [Boost](http://www.boost.org/) 1.57 through 1.69 are supported. Newer versions may work, but
**NOTE:** Versions of [Boost](http://www.boost.org/) 1.58 through 1.69 are supported. Newer versions may work, but
have not been tested. If your system came pre-installed with a version of Boost that you do not wish to use, you may
manually build your preferred version and use it with BitShares by specifying it on the CMake command line.

Expand Down
1 change: 1 addition & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ add_subdirectory( utilities )
add_subdirectory( app )
add_subdirectory( plugins )
add_subdirectory( wallet )
add_subdirectory( protocol )
134 changes: 74 additions & 60 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,28 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/get_config.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/worker_object.hpp>

#include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/thread/future.hpp>

template class fc::api<graphene::app::block_api>;
template class fc::api<graphene::app::network_broadcast_api>;
template class fc::api<graphene::app::network_node_api>;
template class fc::api<graphene::app::history_api>;
template class fc::api<graphene::app::crypto_api>;
template class fc::api<graphene::app::asset_api>;
template class fc::api<graphene::app::orders_api>;
template class fc::api<graphene::debug_witness::debug_api>;
template class fc::api<graphene::app::login_api>;


namespace graphene { namespace app {

login_api::login_api(application& a)
Expand Down Expand Up @@ -317,7 +329,8 @@ namespace graphene { namespace app {
{
FC_ASSERT( _app.chain_database() );
const auto& db = *_app.chain_database();
FC_ASSERT( limit <= 100 );
uint64_t api_limit_get_account_history=_app.get_options().api_limit_get_account_history;
FC_ASSERT( limit <= api_limit_get_account_history );
vector<operation_history_object> result;
account_id_type account;
try {
Expand Down Expand Up @@ -353,7 +366,8 @@ namespace graphene { namespace app {
{
FC_ASSERT( _app.chain_database() );
const auto& db = *_app.chain_database();
FC_ASSERT( limit <= 100 );
uint64_t api_limit_get_account_history_operations=_app.get_options().api_limit_get_account_history_operations;
FC_ASSERT(limit <= api_limit_get_account_history_operations);
vector<operation_history_object> result;
account_id_type account;
try {
Expand Down Expand Up @@ -392,7 +406,8 @@ namespace graphene { namespace app {
{
FC_ASSERT( _app.chain_database() );
const auto& db = *_app.chain_database();
FC_ASSERT(limit <= 100);
uint64_t api_limit_get_relative_account_history=_app.get_options().api_limit_get_relative_account_history;
FC_ASSERT(limit <= api_limit_get_relative_account_history);
vector<operation_history_object> result;
account_id_type account;
try {
Expand All @@ -402,7 +417,7 @@ namespace graphene { namespace app {
if( start == 0 )
start = stats.total_ops;
else
start = min( stats.total_ops, start );
start = std::min( stats.total_ops, start );

if( start >= stop && start > stats.removed_ops && limit > 0 )
{
Expand Down Expand Up @@ -431,7 +446,8 @@ namespace graphene { namespace app {

history_operation_detail history_api::get_account_history_by_operations(const std::string account_id_or_name, vector<uint16_t> operation_types, uint32_t start, unsigned limit)
{
FC_ASSERT(limit <= 100);
uint64_t api_limit_get_account_history_by_operations=_app.get_options().api_limit_get_account_history_by_operations;
FC_ASSERT(limit <= api_limit_get_account_history_by_operations);
history_operation_detail result;
vector<operation_history_object> objs = get_relative_account_history(account_id_or_name, start, limit, limit + start - 1);
std::for_each(objs.begin(), objs.end(), [&](const operation_history_object &o) {
Expand Down Expand Up @@ -530,82 +546,79 @@ namespace graphene { namespace app {

// asset_api
asset_api::asset_api(graphene::app::application& app) :
_db( *app.chain_database()),
database_api( std::ref(*app.chain_database()), &(app.get_options())
) { }
_app(app),
_db( *app.chain_database()),
database_api( std::ref(*app.chain_database()), &(app.get_options())
) { }
asset_api::~asset_api() { }

vector<account_asset_balance> asset_api::get_asset_holders( std::string asset, uint32_t start, uint32_t limit ) const {
FC_ASSERT(limit <= 100);

asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders;
FC_ASSERT(limit <= api_limit_get_asset_holders);
asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );

const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
vector<account_asset_balance> result;

vector<account_asset_balance> result;

uint32_t index = 0;
for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) )
{
if( result.size() >= limit )
break;
uint32_t index = 0;
for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) )
{
if( result.size() >= limit )
break;

if( bal.balance.value == 0 )
continue;
if( bal.balance.value == 0 )
continue;

if( index++ < start )
continue;
if( index++ < start )
continue;

const auto account = _db.find(bal.owner);
const auto account = _db.find(bal.owner);

account_asset_balance aab;
aab.name = account->name;
aab.account_id = account->id;
aab.amount = bal.balance.value;
account_asset_balance aab;
aab.name = account->name;
aab.account_id = account->id;
aab.amount = bal.balance.value;

result.push_back(aab);
}
result.push_back(aab);
}

return result;
return result;
}
// get number of asset holders.
int asset_api::get_asset_holders_count( std::string asset ) const {
const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );

const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
asset_id_type asset_id = database_api.get_asset_id_from_string( asset );
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
int count = boost::distance(range) - 1;

int count = boost::distance(range) - 1;

return count;
return count;
}
// function to get vector of system assets with holders count.
vector<asset_holders> asset_api::get_all_asset_holders() const {
vector<asset_holders> result;
vector<asset_id_type> total_assets;
for( const asset_object& asset_obj : _db.get_index_type<asset_index>().indices() )
{
const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db);

vector<asset_holders> result;

vector<asset_id_type> total_assets;
for( const asset_object& asset_obj : _db.get_index_type<asset_index>().indices() )
{
const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db);

asset_id_type asset_id;
asset_id = dasset_obj.id;
asset_id_type asset_id;
asset_id = dasset_obj.id;

const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );

int count = boost::distance(range) - 1;
int count = boost::distance(range) - 1;

asset_holders ah;
ah.asset_id = asset_id;
ah.count = count;
asset_holders ah;
ah.asset_id = asset_id;
ah.count = count;

result.push_back(ah);
}
result.push_back(ah);
}

return result;
return result;
}

// orders_api
Expand All @@ -622,8 +635,9 @@ namespace graphene { namespace app {
optional<price> start,
uint32_t limit )const
{
FC_ASSERT( limit <= 101 );
auto plugin = _app.get_plugin<grouped_orders_plugin>( "grouped_orders" );
uint64_t api_limit_get_grouped_limit_orders=_app.get_options().api_limit_get_grouped_limit_orders;
FC_ASSERT( limit <= api_limit_get_grouped_limit_orders );
auto plugin = _app.get_plugin<graphene::grouped_orders::grouped_orders_plugin>( "grouped_orders" );
FC_ASSERT( plugin );
const auto& limit_groups = plugin->limit_order_groups();
vector< limit_order_group > result;
Expand Down
Loading

0 comments on commit d98c38a

Please sign in to comment.