Skip to content

Commit

Permalink
HF v0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bravoadam committed Feb 18, 2019
1 parent a5979aa commit a9f4799
Show file tree
Hide file tree
Showing 35 changed files with 244 additions and 1,854 deletions.
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Copyright (c) 2019 BravoCoin <br />
Copyright (c) 2017 Steemit, Inc., and contributors.

The following license applies to code contained within this repository that
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bravo - The Review Blockchain That Pays Its Community
# Bravo - The Decentralized Consumer Review Blockchain That Pays Its Community

Welcome to the official repository for Bravo, the review blockchain that pays its community!

Expand Down
10 changes: 5 additions & 5 deletions contrib/fullnode.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
shared-file-size = 48G

# Set an API to be publicly available, may be specified multiple times
public-api = database_api login_api account_by_key_api network_broadcast_api tag_api follow_api market_history_api raw_block_api
public-api = database_api login_api account_by_key_api network_broadcast_api tag_api follow_api raw_block_api

# Plugin(s) to enable, may be specified multiple times
enable-plugin = witness account_history account_by_key tags follow market_history raw_block
enable-plugin = witness account_history account_by_key tags follow raw_block

# JSON list of [nblocks,nseconds] pairs, see doc/bcd-trigger.md
bcd-trigger = [[0,10],[85,300]]

# Defines a range of accounts to track as a json pair ["from","to"] [from,to]
# track-account-range =

history-whitelist-ops = transfer_operation transfer_to_vesting_operation withdraw_vesting_operation interest_operation transfer_to_savings_operation transfer_from_savings_operation cancel_transfer_from_savings_operation escrow_transfer_operation escrow_approve_operation escrow_dispute_operation escrow_release_operation fill_convert_request_operation fill_order_operation claim_reward_balance_operation author_reward_operation curation_reward_operation fill_vesting_withdraw_operation fill_transfer_from_savings_operation delegate_vesting_shares_operation return_vesting_delegation_operation comment_benefactor_reward_operation
# history-whitelist-ops = transfer_operation transfer_to_vesting_operation withdraw_vesting_operation interest_operation transfer_to_savings_operation transfer_from_savings_operation cancel_transfer_from_savings_operation escrow_transfer_operation escrow_approve_operation escrow_dispute_operation escrow_release_operation fill_convert_request_operation fill_order_operation claim_reward_balance_operation author_reward_operation curation_reward_operation fill_vesting_withdraw_operation fill_transfer_from_savings_operation delegate_vesting_shares_operation return_vesting_delegation_operation comment_benefactor_reward_operation

# Ignore posting operations, only track transfers and account updates
# filter-posting-ops =
Expand Down Expand Up @@ -76,10 +76,10 @@ filename=logs/p2p/p2p.log
# route any messages logged to the default logger to the "stderr" logger we
# declared above, if they are info level are higher
[logger.default]
level=debug
level=warn
appenders=stderr

# route messages sent to the "p2p" logger to stderr too
[logger.p2p]
level=info
level=warn
appenders=stderr
2 changes: 1 addition & 1 deletion doc/seednodes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
18.217.66.193:2001
13.52.15.197:2001
52.32.235.184:2001
185.197.30.13:2001
185.197.30.13:2001
126 changes: 0 additions & 126 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
uint64_t get_witness_count()const;

// Market
order_book get_order_book( uint32_t limit )const;
vector< liquidity_balance > get_liquidity_queue( string start_account, uint32_t limit )const;

// Authority / validation
Expand Down Expand Up @@ -699,131 +698,6 @@ uint64_t database_api_impl::get_witness_count()const
return _db.get_index<witness_index>().indices().size();
}

//////////////////////////////////////////////////////////////////////
// //
// Market //
// //
//////////////////////////////////////////////////////////////////////

order_book database_api::get_order_book( uint32_t limit )const
{
return my->_db.with_read_lock( [&]()
{
return my->get_order_book( limit );
});
}

vector<extended_limit_order> database_api::get_open_orders( string owner )const
{
return my->_db.with_read_lock( [&]()
{
vector<extended_limit_order> result;
const auto& idx = my->_db.get_index<limit_order_index>().indices().get<by_account>();
auto itr = idx.lower_bound( owner );
while( itr != idx.end() && itr->seller == owner ) {
result.push_back( *itr );

if( itr->sell_price.base.symbol == BRAVO_SYMBOL )
result.back().real_price = (~result.back().sell_price).to_real();
else
result.back().real_price = (result.back().sell_price).to_real();
++itr;
}
return result;
});
}

order_book database_api_impl::get_order_book( uint32_t limit )const
{
FC_ASSERT( limit <= 1000 );
order_book result;

auto max_sell = price::max( BBD_SYMBOL, BRAVO_SYMBOL );
auto max_buy = price::max( BRAVO_SYMBOL, BBD_SYMBOL );

const auto& limit_price_idx = _db.get_index<limit_order_index>().indices().get<by_price>();
auto sell_itr = limit_price_idx.lower_bound(max_sell);
auto buy_itr = limit_price_idx.lower_bound(max_buy);
auto end = limit_price_idx.end();
// idump((max_sell)(max_buy));
// if( sell_itr != end ) idump((*sell_itr));
// if( buy_itr != end ) idump((*buy_itr));

while( sell_itr != end && sell_itr->sell_price.base.symbol == BBD_SYMBOL && result.bids.size() < limit )
{
auto itr = sell_itr;
order cur;
cur.order_price = itr->sell_price;
cur.real_price = (cur.order_price).to_real();
cur.sbd = itr->for_sale;
cur.bravo = ( asset( itr->for_sale, BBD_SYMBOL ) * cur.order_price ).amount;
cur.created = itr->created;
result.bids.push_back( cur );
++sell_itr;
}
while( buy_itr != end && buy_itr->sell_price.base.symbol == BRAVO_SYMBOL && result.asks.size() < limit )
{
auto itr = buy_itr;
order cur;
cur.order_price = itr->sell_price;
cur.real_price = (~cur.order_price).to_real();
cur.bravo = itr->for_sale;
cur.sbd = ( asset( itr->for_sale, BRAVO_SYMBOL ) * cur.order_price ).amount;
cur.created = itr->created;
result.asks.push_back( cur );
++buy_itr;
}


return result;
}

vector< liquidity_balance > database_api::get_liquidity_queue( string start_account, uint32_t limit )const
{
return my->_db.with_read_lock( [&]()
{
return my->get_liquidity_queue( start_account, limit );
});
}

vector< liquidity_balance > database_api_impl::get_liquidity_queue( string start_account, uint32_t limit )const
{
FC_ASSERT( limit <= 1000 );

const auto& liq_idx = _db.get_index< liquidity_reward_balance_index >().indices().get< by_volume_weight >();
auto itr = liq_idx.begin();
vector< liquidity_balance > result;

result.reserve( limit );

if( start_account.length() )
{
const auto& liq_by_acc = _db.get_index< liquidity_reward_balance_index >().indices().get< by_owner >();
auto acc = liq_by_acc.find( _db.get_account( start_account ).id );

if( acc != liq_by_acc.end() )
{
itr = liq_idx.find( boost::make_tuple( acc->weight, acc->owner ) );
}
else
{
itr = liq_idx.end();
}
}

while( itr != liq_idx.end() && result.size() < limit )
{
liquidity_balance bal;
bal.account = _db.get(itr->owner).name;
bal.weight = itr->weight;
result.push_back( bal );

++itr;
}

return result;
}

//////////////////////////////////////////////////////////////////////
// //
// Authority / validation //
Expand Down
23 changes: 0 additions & 23 deletions libraries/app/include/bravo/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,6 @@ class database_api
*/
uint64_t get_witness_count()const;

////////////
// Market //
////////////

/**
* @breif Gets the current order book for BRAVO:SBD market
* @param limit Maximum number of orders for each side of the spread to return -- Must not exceed 1000
*/
order_book get_order_book( uint32_t limit = 1000 )const;
vector<extended_limit_order> get_open_orders( string owner )const;

/**
* @breif Gets the current liquidity reward queue.
* @param start_account The account to start the list from, or "" to get the head of the queue
* @param limit Maxmimum number of accounts to return -- Must not exceed 1000
*/
vector< liquidity_balance > get_liquidity_queue( string start_account, uint32_t limit = 1000 )const;

////////////////////////////
// Authority / validation //
////////////////////////////
Expand Down Expand Up @@ -498,11 +480,6 @@ FC_API(bravo::app::database_api,
(get_savings_withdraw_from)
(get_savings_withdraw_to)

// Market
(get_order_book)
(get_open_orders)
(get_liquidity_queue)

// Authority / validation
(get_transaction_hex)
(get_transaction)
Expand Down
35 changes: 9 additions & 26 deletions libraries/chain/bravo_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void comment_evaluator::do_apply( const comment_operation& o )
from_string( com.parent_permlink, o.parent_permlink );
from_string( com.category, o.parent_permlink );
com.root_comment = com.id;
}
}
else
{
com.parent_author = parent->author;
Expand Down Expand Up @@ -765,7 +765,10 @@ void account_witness_proxy_evaluator::do_apply( const account_witness_proxy_oper

/// remove all current votes
std::array<share_type, BRAVO_MAX_PROXY_RECURSION_DEPTH+1> delta;
//delta[0] = -account.vesting_shares.amount;

if (_db.has_hardfork(BRAVO_HARDFORK_0_21))
delta[0] = -account.effective_bravo_balance().amount;

for( int i = 0; i < BRAVO_MAX_PROXY_RECURSION_DEPTH; ++i )
delta[i+1] = -account.proxied_vsf_votes[i];
_db.adjust_proxied_witness_votes( account, delta );
Expand Down Expand Up @@ -826,7 +829,7 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat
v.account = voter.id;
});

_db.adjust_witness_vote( witness, voter.witness_vote_weight() );
_db.adjust_witness_vote( witness, voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21)));

_db.modify( voter, [&]( account_object& a ) {
a.witnesses_voted_for++;
Expand All @@ -835,7 +838,7 @@ void account_witness_vote_evaluator::do_apply( const account_witness_vote_operat
} else {
FC_ASSERT( !o.approve, "Vote currently exists, user must indicate a desire to reject witness." );

_db.adjust_witness_vote( witness, -voter.witness_vote_weight() );
_db.adjust_witness_vote( witness, -voter.witness_vote_weight(_db.has_hardfork(BRAVO_HARDFORK_0_21)) );
_db.modify( voter, [&]( account_object& a ) {
a.witnesses_voted_for--;
});
Expand Down Expand Up @@ -1354,27 +1357,7 @@ void convert_evaluator::do_apply( const convert_operation& o )

void limit_order_create_evaluator::do_apply( const limit_order_create_operation& o )
{
FC_ASSERT( o.expiration > _db.head_block_time(), "Limit order has to expire after head block time." );

const auto& owner = _db.get_account( o.owner );

FC_ASSERT( _db.get_balance( owner, o.amount_to_sell.symbol ) >= o.amount_to_sell, "Account does not have sufficient funds for limit order." );

_db.adjust_balance( owner, -o.amount_to_sell );

const auto& order = _db.create<limit_order_object>( [&]( limit_order_object& obj )
{
obj.created = _db.head_block_time();
obj.seller = o.owner;
obj.orderid = o.orderid;
obj.for_sale = o.amount_to_sell.amount;
obj.sell_price = o.get_price();
obj.expiration = o.expiration;
});

bool filled = _db.apply_order( order );

if( o.fill_or_kill ) FC_ASSERT( filled, "Cancelling order because it was not filled." );
FC_ASSERT(false, "limit_order_create_operation is disabled.");
}

void limit_order_create2_evaluator::do_apply( const limit_order_create2_operation& o )
Expand Down Expand Up @@ -1404,7 +1387,7 @@ void limit_order_create2_evaluator::do_apply( const limit_order_create2_operatio

void limit_order_cancel_evaluator::do_apply( const limit_order_cancel_operation& o )
{
_db.cancel_order( _db.get_limit_order( o.owner, o.orderid ) );
FC_ASSERT(false, "limit_order_cancel_operation is disabled.");
}

void report_over_production_evaluator::do_apply( const report_over_production_operation& o )
Expand Down
Loading

0 comments on commit a9f4799

Please sign in to comment.