Skip to content

Commit

Permalink
Merge pull request #670 from bitshares/develop
Browse files Browse the repository at this point in the history
Merge develop branch to hardfork branch
  • Loading branch information
abitmore authored Feb 15, 2018
2 parents 2a7ba60 + dfb3a49 commit 4a1f131
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 213 deletions.
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fc::uint128 to_capped128( const u256& t )
string uint128_amount_to_string( const fc::uint128& amount, const uint8_t precision )
{ try {
string s = string( amount );
if( precision == 0 || amount == 0 )
if( precision == 0 || amount == fc::uint128() )
return s;

std::stringstream ss;
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ processed_transaction database::_push_transaction( const signed_transaction& trx
temp_session.merge();

// notify anyone listening to pending transactions
on_pending_transaction( trx );
notify_on_pending_transaction( trx );
return processed_trx;
}

Expand Down Expand Up @@ -286,7 +286,7 @@ processed_transaction database::push_proposal(const proposal_object& proposal)
{
_applied_ops.resize( old_applied_ops_size );
}
elog( "e", ("e",e.to_detail_string() ) );
elog( "${e}", ("e",e.to_detail_string() ) );
throw;
}

Expand Down Expand Up @@ -538,7 +538,7 @@ void database::_apply_block( const signed_block& next_block )
apply_debug_updates();

// notify observers that the block has been applied
applied_block( next_block ); //emit
notify_applied_block( next_block ); //emit
_applied_ops.clear();

notify_changed_objects();
Expand Down
5 changes: 0 additions & 5 deletions libraries/chain/db_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
const auto& assets_by_symbol = get_index_type<asset_index>().indices().get<by_symbol>();
const auto get_asset_id = [&assets_by_symbol](const string& symbol) {
auto itr = assets_by_symbol.find(symbol);

// TODO: This is temporary for handling BTS snapshot
if( symbol == "BTS" )
itr = assets_by_symbol.find(GRAPHENE_SYMBOL);

FC_ASSERT(itr != assets_by_symbol.end(),
"Unable to find asset '${sym}'. Did you forget to add a record for it to initial_assets?",
("sym", symbol));
Expand Down
16 changes: 13 additions & 3 deletions libraries/chain/db_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ static void get_relevant_accounts( const object* obj, flat_set<account_id_type>&

namespace graphene { namespace chain {

void database::notify_applied_block( const signed_block& block )
{
GRAPHENE_TRY_NOTIFY( applied_block, block )
}

void database::notify_on_pending_transaction( const signed_transaction& tx )
{
GRAPHENE_TRY_NOTIFY( on_pending_transaction, tx )
}

void database::notify_changed_objects()
{ try {
if( _undo_db.enabled() )
Expand All @@ -372,7 +382,7 @@ void database::notify_changed_objects()
get_relevant_accounts(obj, new_accounts_impacted);
}

new_objects(new_ids, new_accounts_impacted);
GRAPHENE_TRY_NOTIFY( new_objects, new_ids, new_accounts_impacted)
}

// Changed
Expand All @@ -386,7 +396,7 @@ void database::notify_changed_objects()
get_relevant_accounts(item.second.get(), changed_accounts_impacted);
}

changed_objects(changed_ids, changed_accounts_impacted);
GRAPHENE_TRY_NOTIFY( changed_objects, changed_ids, changed_accounts_impacted)
}

// Removed
Expand All @@ -403,7 +413,7 @@ void database::notify_changed_objects()
get_relevant_accounts(obj, removed_accounts_impacted);
}

removed_objects(removed_ids, removed, removed_accounts_impacted);
GRAPHENE_TRY_NOTIFY( removed_objects, removed_ids, removed, removed_accounts_impacted)
}
}
} FC_CAPTURE_AND_LOG( (0) ) }
Expand Down
6 changes: 1 addition & 5 deletions libraries/chain/include/graphene/chain/asset_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,10 @@ namespace graphene { namespace chain {
void update_median_feeds(time_point_sec current_time);
};

struct by_feed_expiration;
typedef multi_index_container<
asset_bitasset_data_object,
indexed_by<
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
ordered_non_unique< tag<by_feed_expiration>,
const_mem_fun< asset_bitasset_data_object, time_point_sec, &asset_bitasset_data_object::feed_expiration_time >
>
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >
>
> asset_bitasset_data_object_multi_index_type;
typedef generic_index<asset_bitasset_data_object, asset_bitasset_data_object_multi_index_type> asset_bitasset_data_index;
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/graphene/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ namespace graphene { namespace chain {
protected:
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
void pop_undo() { object_database::pop_undo(); }
void notify_applied_block( const signed_block& block );
void notify_on_pending_transaction( const signed_transaction& tx );
void notify_changed_objects();

private:
Expand Down
16 changes: 16 additions & 0 deletions libraries/chain/include/graphene/chain/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
msg \
)

#define GRAPHENE_TRY_NOTIFY( signal, ... ) \
try \
{ \
signal( __VA_ARGS__ ); \
} \
catch( const graphene::chain::plugin_exception& e ) \
{ \
elog( "Caught plugin exception: ${e}", ("e", e.to_detail_string() ) ); \
throw; \
} \
catch( ... ) \
{ \
wlog( "Caught unexpected exception in plugin" ); \
}

namespace graphene { namespace chain {

FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
Expand All @@ -77,6 +92,7 @@ namespace graphene { namespace chain {
FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, graphene::chain::chain_exception, 3070000, "undo database exception" )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::chain::chain_exception, 3080000, "unlinkable block" )
FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, graphene::chain::chain_exception, 3090000, "black swan" )
FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, graphene::chain::chain_exception, 3100000, "plugin exception" )

FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::chain::transaction_exception, 3030001, "missing required active authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::chain::transaction_exception, 3030002, "missing required owner authority" )
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/include/graphene/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ namespace graphene { namespace chain {
friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2);
friend bool operator == ( const public_key_type& p1, const public_key_type& p2);
friend bool operator != ( const public_key_type& p1, const public_key_type& p2);
// TODO: This is temporary for testing
bool is_valid_v1( const std::string& base58str );
};

struct extended_public_key_type
Expand Down
43 changes: 0 additions & 43 deletions libraries/chain/index.cpp

This file was deleted.

9 changes: 1 addition & 8 deletions libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope
else if( _bitasset_data->current_feed.settlement_price.is_null() )
FC_THROW_EXCEPTION(insufficient_feeds, "Cannot borrow asset with no price feed.");

if( o.delta_debt.amount < 0 )
{
FC_ASSERT( d.get_balance(*_paying_account, *_debt_asset) >= o.delta_debt,
"Cannot cover by ${c} when payer only has ${b}",
("c", o.delta_debt.amount)("b", d.get_balance(*_paying_account, *_debt_asset).amount) );
}

if( o.delta_collateral.amount > 0 )
{
FC_ASSERT( d.get_balance(*_paying_account, _bitasset_data->options.short_backing_asset(d)) >= o.delta_collateral,
Expand All @@ -197,7 +190,7 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
// Deduct the debt paid from the total supply of the debt asset.
d.modify(_debt_asset->dynamic_asset_data_id(d), [&](asset_dynamic_data_object& dynamic_asset) {
dynamic_asset.current_supply += o.delta_debt.amount;
assert(dynamic_asset.current_supply >= 0);
FC_ASSERT(dynamic_asset.current_supply >= 0);
});
}

Expand Down
25 changes: 0 additions & 25 deletions libraries/chain/protocol/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ namespace graphene { namespace chain {
// TODO: Refactor syntactic checks into static is_valid()
// to make public_key_type API more similar to address API
std::string prefix( GRAPHENE_ADDRESS_PREFIX );

// TODO: This is temporary for testing
try
{
if( is_valid_v1( base58str ) )
prefix = std::string( "BTS" );
}
catch( ... )
{
}

const size_t prefix_len = prefix.size();
FC_ASSERT( base58str.size() > prefix_len );
FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) );
Expand All @@ -64,20 +53,6 @@ namespace graphene { namespace chain {
FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check );
};

// TODO: This is temporary for testing
bool public_key_type::is_valid_v1( const std::string& base58str )
{
std::string prefix( "BTS" );
const size_t prefix_len = prefix.size();
FC_ASSERT( base58str.size() > prefix_len );
FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) );
auto bin = fc::from_base58( base58str.substr( prefix_len ) );
auto bin_key = fc::raw::unpack<binary_key>(bin);
fc::ecc::public_key_data key_data = bin_key.data;
FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check );
return true;
}

public_key_type::operator fc::ecc::public_key_data() const
{
return key_data;
Expand Down
Loading

0 comments on commit 4a1f131

Please sign in to comment.