Skip to content

Commit

Permalink
Merge branch 'hardfork' into 201803-market-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Apr 3, 2018
2 parents 640023a + a9cb440 commit 5413461
Show file tree
Hide file tree
Showing 116 changed files with 4,890 additions and 1,152 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: c++

git:
depth: 1

dist: trusty

sudo: true

install:
- echo "deb http://de.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update
- sudo apt-get install --allow-unauthenticated g++ libboost-all-dev cmake libreadline-dev libssl-dev autoconf

script:
- cmake -DCMAKE_BUILD_TYPE=Debug -DBoost_USE_STATIC_LIBS=OFF .
- make -j 2

6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ if( WIN32 )

else( WIN32 ) # Apple AND Linux

find_library(READLINE_LIBRARIES NAMES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
#if(NOT READLINE_INCLUDE_DIR OR NOT READLINE_LIBRARIES)
# MESSAGE(FATAL_ERROR "Could not find lib readline.")
#endif()

if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring BitShares on OS X" )
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ WORKDIR /bitshares-core

# Compile
RUN \
git submodule sync --recursive && \
git submodule update --init --recursive && \
cmake \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
10 changes: 5 additions & 5 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "Graphene"
PROJECT_NAME = "Bitshares-Core"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER =
PROJECT_NUMBER = "2.0.180202"

# 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
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF =
PROJECT_BRIEF = "Your share in the Decentralized Exchange"

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down Expand Up @@ -758,7 +758,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = doc/main.dox libraries/chain libraries/chain/db libraries/app libraries/wallet
INPUT = README.md doc/main.dox libraries/chain libraries/chain/db libraries/app libraries/wallet

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -894,7 +894,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.

USE_MDFILE_AS_MAINPAGE =
USE_MDFILE_AS_MAINPAGE = "README.md"

#---------------------------------------------------------------------------
# Configuration options related to source browsing
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
BitShares Core
==============

[Build Status](https://travis-ci.org/bitshares/bitshares-core/branches):

`master` | `develop` | `hardfork` | `testnet` | `bitshares-fc`
--- | --- | --- | --- | ---
[![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=master)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=develop)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=hardfork)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=testnet)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-fc.svg?branch=master)](https://travis-ci.org/bitshares/bitshares-fc)


* [Getting Started](#getting-started)
* [Support](#support)
* [Using the API](#using-the-api)
Expand Down Expand Up @@ -86,6 +94,8 @@ BitShares Core bugs can be reported directly to the [issue tracker](https://gith

BitShares UI bugs should be reported to the [UI issue tracker](https://github.com/bitshares/bitshares-ui/issues)

Up to date online Doxygen documentation can be found at [Doxygen](https://bitshares.org/doxygen/hierarchy.html)

Using the API
-------------

Expand Down
2 changes: 1 addition & 1 deletion libraries/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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_utilities graphene_debug_witness )
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_grouped_orders graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness )
target_include_directories( graphene_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
Expand Down
85 changes: 66 additions & 19 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace graphene { namespace app {
{
if( api_name == "database_api" )
{
_database_api = std::make_shared< database_api >( std::ref( *_app.chain_database() ) );
_database_api = std::make_shared< database_api >( std::ref( *_app.chain_database() ), &( _app.get_options() ) );
}
else if( api_name == "block_api" )
{
Expand All @@ -104,6 +104,10 @@ namespace graphene { namespace app {
{
_asset_api = std::make_shared< asset_api >( std::ref( *_app.chain_database() ) );
}
else if( api_name == "orders_api" )
{
_orders_api = std::make_shared< orders_api >( std::ref( _app ) );
}
else if( api_name == "debug_api" )
{
// can only enable this API if the plugin was loaded
Expand Down Expand Up @@ -147,7 +151,7 @@ namespace graphene { namespace app {
{
auto block_num = b.block_num();
auto& callback = _callbacks.find(id)->second;
fc::async( [capture_this,this,id,block_num,trx_num,trx,callback](){ callback( fc::variant(transaction_confirmation{ id, block_num, trx_num, trx}) ); } );
fc::async( [capture_this,this,id,block_num,trx_num,trx,callback](){ callback( fc::variant(transaction_confirmation{ id, block_num, trx_num, trx}, 5) ); } );
}
}
}
Expand Down Expand Up @@ -262,6 +266,12 @@ namespace graphene { namespace app {
return *_asset_api;
}

fc::api<orders_api> login_api::orders() const
{
FC_ASSERT(_orders_api);
return *_orders_api;
}

fc::api<graphene::debug_witness::debug_api> login_api::debug() const
{
FC_ASSERT(_debug_api);
Expand Down Expand Up @@ -302,26 +312,27 @@ namespace graphene { namespace app {
const auto& db = *_app.chain_database();
FC_ASSERT( limit <= 100 );
vector<operation_history_object> result;
const auto& stats = account(db).statistics(db);
if( stats.most_recent_op == account_transaction_history_id_type() ) return result;
const account_transaction_history_object* node = &stats.most_recent_op(db);
if( start == operation_history_id_type() )
start = node->operation_id;

while(node && node->operation_id.instance.value > stop.instance.value && result.size() < limit)
try {
const account_transaction_history_object& node = account(db).statistics(db).most_recent_op(db);
if(start == operation_history_id_type() || start.instance.value > node.operation_id.instance.value)
start = node.operation_id;
} catch(...) { return result; }

const auto& hist_idx = db.get_index_type<account_transaction_history_index>();
const auto& by_op_idx = hist_idx.indices().get<by_op>();
auto index_start = by_op_idx.begin();
auto itr = by_op_idx.lower_bound(boost::make_tuple(account, start));

while(itr != index_start && itr->account == account && itr->operation_id.instance.value > stop.instance.value && result.size() < limit)
{
if( node->operation_id.instance.value <= start.instance.value )
result.push_back( node->operation_id(db) );
if( node->next == account_transaction_history_id_type() )
node = nullptr;
else node = &node->next(db);
if(itr->operation_id.instance.value <= start.instance.value)
result.push_back(itr->operation_id(db));
--itr;
}
if( stop.instance.value == 0 && result.size() < limit )
{
node = db.find(account_transaction_history_id_type());
if( node && node->account == account)
result.push_back( node->operation_id(db) );
if(stop.instance.value == 0 && result.size() < limit && itr->account == account) {
result.push_back(itr->operation_id(db));
}

return result;
}

Expand Down Expand Up @@ -587,4 +598,40 @@ namespace graphene { namespace app {
return result;
}

// orders_api
flat_set<uint16_t> orders_api::get_tracked_groups()const
{
auto plugin = _app.get_plugin<grouped_orders_plugin>( "grouped_orders" );
FC_ASSERT( plugin );
return plugin->tracked_groups();
}

vector< limit_order_group > orders_api::get_grouped_limit_orders( asset_id_type base_asset_id,
asset_id_type quote_asset_id,
uint16_t group,
optional<price> start,
uint32_t limit )const
{
FC_ASSERT( limit <= 101 );
auto plugin = _app.get_plugin<grouped_orders_plugin>( "grouped_orders" );
FC_ASSERT( plugin );
const auto& limit_groups = plugin->limit_order_groups();
vector< limit_order_group > result;

price max_price = price::max( base_asset_id, quote_asset_id );
price min_price = price::min( base_asset_id, quote_asset_id );
if( start.valid() && !start->is_null() )
max_price = std::max( std::min( max_price, *start ), min_price );

auto itr = limit_groups.lower_bound( limit_order_group_key( group, max_price ) );
// use an end itrator to try to avoid expensive price comparison
auto end = limit_groups.upper_bound( limit_order_group_key( group, min_price ) );
while( itr != end && result.size() < limit )
{
result.emplace_back( *itr );
++itr;
}
return result;
}

} } // graphene::app
Loading

0 comments on commit 5413461

Please sign in to comment.