Skip to content

Commit

Permalink
Merge pull request #797 from bitshares/release
Browse files Browse the repository at this point in the history
Merge release branch into master branch
  • Loading branch information
abitmore authored Mar 28, 2018
2 parents 96c0c27 + 3312236 commit 92eb45c
Show file tree
Hide file tree
Showing 101 changed files with 3,771 additions and 1,074 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: 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
97 changes: 75 additions & 22 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,10 @@ 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 },
GRAPHENE_MAX_NESTED_OBJECTS ) );
} );
}
}
}
Expand All @@ -157,7 +164,8 @@ namespace graphene { namespace app {
{
trx.validate();
_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast_transaction(trx);
}

fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
Expand All @@ -173,15 +181,17 @@ namespace graphene { namespace app {
void network_broadcast_api::broadcast_block( const signed_block& b )
{
_app.chain_database()->push_block(b);
_app.p2p_node()->broadcast( net::block_message( b ));
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast( net::block_message( b ));
}

void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction& trx)
{
trx.validate();
_callbacks[trx.id()] = cb;
_app.chain_database()->push_transaction(trx);
_app.p2p_node()->broadcast_transaction(trx);
if( _app.p2p_node() != nullptr )
_app.p2p_node()->broadcast_transaction(trx);
}

network_node_api::network_node_api( application& a ) : _app( a )
Expand Down Expand Up @@ -262,6 +272,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 +318,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 +604,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 92eb45c

Please sign in to comment.