Skip to content

Commit

Permalink
Remove deprecated id(db) syntax steemit#687
Browse files Browse the repository at this point in the history
  • Loading branch information
theoreticalbts committed Dec 9, 2016
1 parent 0dfef17 commit 4f197c6
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 52 deletions.
22 changes: 11 additions & 11 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ witness_schedule_api_obj database_api::get_witness_schedule()const
{
return my->_db.with_read_lock( [&]()
{
return witness_schedule_id_type()( my->_db );
return my->_db.get(witness_schedule_id_type());
});
}

hardfork_version database_api::get_hardfork_version()const
{
return my->_db.with_read_lock( [&]()
{
return hardfork_property_id_type()( my->_db ).current_hardfork_version;
return my->_db.get(hardfork_property_id_type()).current_hardfork_version;
});
}

Expand All @@ -326,7 +326,7 @@ scheduled_hardfork database_api::get_next_scheduled_hardfork() const
return my->_db.with_read_lock( [&]()
{
scheduled_hardfork shf;
const auto& hpo = hardfork_property_id_type()( my->_db );
const auto& hpo = my->_db.get(hardfork_property_id_type());
shf.hf_version = hpo.next_hardfork;
shf.live_time = hpo.next_hardfork_time;
return shf;
Expand Down Expand Up @@ -391,7 +391,7 @@ vector< extended_account > database_api_impl::get_accounts( vector< string > nam

auto vitr = vidx.lower_bound( boost::make_tuple( itr->id, witness_id_type() ) );
while( vitr != vidx.end() && vitr->account == itr->id ) {
results.back().witness_votes.insert(vitr->witness(_db).owner);
results.back().witness_votes.insert(_db.get(vitr->witness).owner);
++vitr;
}
}
Expand Down Expand Up @@ -560,7 +560,7 @@ vector< withdraw_route > database_api::get_withdraw_routes( string account, with
{
withdraw_route r;
r.from_account = account;
r.to_account = route->to_account( my->_db ).name;
r.to_account = my->_db.get( route->to_account ).name;
r.percent = route->percent;
r.auto_vest = route->auto_vest;

Expand All @@ -578,7 +578,7 @@ vector< withdraw_route > database_api::get_withdraw_routes( string account, with
while( route != by_dest.end() && route->to_account == acc.id )
{
withdraw_route r;
r.from_account = route->from_account( my->_db ).name;
r.from_account = my->_db.get( route->from_account ).name;
r.to_account = account;
r.percent = route->percent;
r.auto_vest = route->auto_vest;
Expand Down Expand Up @@ -823,7 +823,7 @@ vector< liquidity_balance > database_api_impl::get_liquidity_queue( string start
while( itr != liq_idx.end() && result.size() < limit )
{
liquidity_balance bal;
bal.account = itr->owner( _db ).name;
bal.account = _db.get(itr->owner).name;
bal.weight = itr->weight;
result.push_back( bal );

Expand Down Expand Up @@ -1000,7 +1000,7 @@ vector<vote_state> database_api::get_active_votes( string author, string permlin
auto itr = idx.lower_bound( cid );
while( itr != idx.end() && itr->comment == cid )
{
const auto& vo = itr->voter(my->_db);
const auto& vo = my->_db.get(itr->voter);
vote_state vstate;
vstate.voter = vo.name;
vstate.weight = itr->weight;
Expand Down Expand Up @@ -1036,7 +1036,7 @@ vector<account_vote> database_api::get_account_votes( string voter )const
auto end = idx.upper_bound( aid );
while( itr != end )
{
const auto& vo = itr->comment(my->_db);
const auto& vo = my->_db.get(itr->comment);
account_vote avote;
avote.authorperm = vo.author+"/"+to_string( vo.permlink );
avote.weight = itr->weight;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ map< uint32_t, applied_operation > database_api::get_account_history( string acc
map<uint32_t, applied_operation> result;
while( itr != end )
{
result[itr->sequence] = itr->op(my->_db);
result[itr->sequence] = my->_db.get(itr->op);
++itr;
}
return result;
Expand Down Expand Up @@ -1235,7 +1235,7 @@ vector<tag_api_obj> database_api::get_trending_tags( string after, uint32_t limi

discussion database_api::get_discussion( comment_id_type id )const
{
discussion d = id(my->_db);
discussion d = my->_db.get(id);
set_url( d );
set_pending_payout( d );
d.active_votes = get_active_votes( d.author, d.permlink );
Expand Down
22 changes: 11 additions & 11 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ void database::adjust_witness_votes( const account_object& a, share_type delta )
auto itr = vidx.lower_bound( boost::make_tuple( a.id, witness_id_type() ) );
while( itr != vidx.end() && itr->account == a.id )
{
adjust_witness_vote( itr->witness(*this), delta );
adjust_witness_vote( get(itr->witness), delta );
++itr;
}
}
Expand Down Expand Up @@ -1791,7 +1791,7 @@ void database::process_vesting_withdrawals()

if( to_deposit > 0 )
{
const auto& to_account = itr->to_account( *this );
const auto& to_account = get(itr->to_account);

modify( to_account, [&]( account_object& a )
{
Expand All @@ -1811,7 +1811,7 @@ void database::process_vesting_withdrawals()
{
if( !itr->auto_vest )
{
const auto& to_account = itr->to_account( *this );
const auto& to_account = get(itr->to_account);

share_type to_deposit = ( ( fc::uint128_t ( to_withdraw.value ) * itr->percent ) / STEEMIT_100_PERCENT ).to_uint64();
vests_deposited_as_steem += to_deposit;
Expand Down Expand Up @@ -1904,7 +1904,7 @@ share_type database::pay_discussions( const comment_object& c, share_type max_re
// Pre-order traversal of the tree of child comments
while( child_queue.size() )
{
const auto& cur = child_queue.front()( *this );
const auto& cur = get(child_queue.front());
child_queue.pop_front();

if( cur.net_rshares > 0 )
Expand Down Expand Up @@ -1957,7 +1957,7 @@ share_type database::pay_curators( const comment_object& c, share_type max_rewar
if( claim > 0 ) // min_amt is non-zero satoshis
{
unclaimed_rewards -= claim;
const auto& voter = itr->voter(*this);
const auto& voter = get(itr->voter);
auto reward = create_vesting( voter, asset( claim, STEEM_SYMBOL ) );

push_virtual_operation( curation_reward_operation( voter.name, reward, c.author, to_string( c.permlink ) ) );
Expand Down Expand Up @@ -2334,7 +2334,7 @@ void database::pay_liquidity_reward()
if( itr != ridx.end() && itr->volume_weight() > 0 )
{
adjust_supply( reward, true );
adjust_balance( itr->owner(*this), reward );
adjust_balance( get(itr->owner), reward );
modify( *itr, [&]( liquidity_reward_balance_object& obj )
{
obj.steem_volume = 0;
Expand All @@ -2343,7 +2343,7 @@ void database::pay_liquidity_reward()
obj.weight = 0;
} );

push_virtual_operation( liquidity_reward_operation( itr->owner( *this ).name, reward ) );
push_virtual_operation( liquidity_reward_operation( get(itr->owner).name, reward ) );
}
}
}
Expand Down Expand Up @@ -2538,7 +2538,7 @@ void database::process_decline_voting_rights()

while( itr != request_idx.end() && itr->effective_date <= head_block_time() )
{
const auto& account = itr->account(*this);
const auto& account = get(itr->account);

/// remove all current votes
std::array<share_type, STEEMIT_MAX_PROXY_RECURSION_DEPTH+1> delta;
Expand All @@ -2549,7 +2549,7 @@ void database::process_decline_voting_rights()

clear_witness_votes( account );

modify( itr->account(*this), [&]( account_object& a )
modify( get(itr->account), [&]( account_object& a )
{
a.can_vote = false;
a.proxy = STEEMIT_PROXY_TO_SELF_ACCOUNT;
Expand Down Expand Up @@ -3311,7 +3311,7 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
{
FC_ASSERT( head_block_id() == next_block.previous, "", ("head_block_id",head_block_id())("next.prev",next_block.previous) );
FC_ASSERT( head_block_time() < next_block.timestamp, "", ("head_block_time",head_block_time())("next",next_block.timestamp)("blocknum",next_block.block_num()) );
const witness_object& witness = get_witness( next_block.witness ); //(*this);
const witness_object& witness = get_witness( next_block.witness );

if( !(skip&skip_witness_signature) )
FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
Expand Down Expand Up @@ -4479,7 +4479,7 @@ void database::retally_witness_votes()
auto wit_itr = vidx.lower_bound( boost::make_tuple( a.id, witness_id_type() ) );
while( wit_itr != vidx.end() && wit_itr->account == a.id )
{
adjust_witness_vote( wit_itr->witness(*this), a.witness_vote_weight() );
adjust_witness_vote( get(wit_itr->witness), a.witness_vote_weight() );
++wit_itr;
}
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void comment_evaluator::do_apply( const comment_operation& o )
{
if( o.parent_author != STEEMIT_ROOT_POST_PARENT )
{
FC_ASSERT( parent->root_comment( _db ).allow_replies, "The parent comment has disabled replies." );
FC_ASSERT( _db.get( parent->root_comment ).allow_replies, "The parent comment has disabled replies." );
if( _db.has_hardfork( STEEMIT_HARDFORK_0_12__177) )
FC_ASSERT( _db.calculate_discussion_payout_time( *parent ) != fc::time_point_sec::maximum(), "Discussion is frozen." );
}
Expand Down Expand Up @@ -1116,7 +1116,7 @@ void vote_evaluator::do_apply( const vote_operation& o )

/// if the current net_rshares is less than 0, the post is getting 0 rewards so it is not factored into total rshares^2
fc::uint128_t old_rshares = std::max(comment.net_rshares.value, int64_t(0));
const auto& root = comment.root_comment( _db );
const auto& root = _db.get( comment.root_comment );
auto old_root_abs_rshares = root.children_abs_rshares.value;

fc::uint128_t cur_cashout_time_sec = _db.calculate_discussion_payout_time( comment ).sec_since_epoch();
Expand Down Expand Up @@ -1276,7 +1276,7 @@ void vote_evaluator::do_apply( const vote_operation& o )

/// if the current net_rshares is less than 0, the post is getting 0 rewards so it is not factored into total rshares^2
fc::uint128_t old_rshares = std::max(comment.net_rshares.value, int64_t(0));
const auto& root = comment.root_comment( _db );
const auto& root = _db.get( comment.root_comment );
auto old_root_abs_rshares = root.children_abs_rshares.value;

fc::uint128_t cur_cashout_time_sec = _db.calculate_discussion_payout_time( comment ).sec_since_epoch();
Expand Down
2 changes: 1 addition & 1 deletion libraries/chainbase
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace detail
statistics blockchain_statistics_api_impl::get_lifetime_stats()const
{
statistics result;
result += bucket_id_type()( *( _app.chain_database() ) );
result += _app.chain_database()->get( bucket_id_type() );

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void blockchain_statistics_plugin_impl::on_block( const signed_block& b )
}
else
{
db.modify( bucket_id_type()( db ), [&]( bucket_object& bo )
db.modify( db.get( bucket_id_type() ), [&]( bucket_object& bo )
{
bo.blocks++;
});
Expand Down Expand Up @@ -341,7 +341,7 @@ void blockchain_statistics_plugin_impl::pre_operation( const operation_notificat
{
delete_comment_operation op = o.op.get< delete_comment_operation >();
auto comment = db.get_comment( op.author, op.permlink );
const auto& bucket = bucket_id( db );
const auto& bucket = db.get(bucket_id);

db.modify( bucket, [&]( bucket_object& b )
{
Expand All @@ -355,7 +355,7 @@ void blockchain_statistics_plugin_impl::pre_operation( const operation_notificat
{
withdraw_vesting_operation op = o.op.get< withdraw_vesting_operation >();
auto& account = db.get_account( op.account );
const auto& bucket = bucket_id( db );
const auto& bucket = db.get(bucket_id);

auto new_vesting_withdrawal_rate = op.vesting_shares.amount / STEEMIT_VESTING_WITHDRAW_INTERVALS;
if( op.vesting_shares.amount > 0 && new_vesting_withdrawal_rate == 0 )
Expand Down Expand Up @@ -386,7 +386,7 @@ void blockchain_statistics_plugin_impl::post_operation( const operation_notifica

for( auto bucket_id : _current_buckets )
{
const auto& bucket = bucket_id( db );
const auto& bucket = db.get(bucket_id);

if( !is_virtual_operation( o.op ) )
{
Expand Down
7 changes: 3 additions & 4 deletions libraries/plugins/debug_node/debug_node_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ fc::optional< steemit::chain::signed_block > debug_node_api_impl::debug_pop_bloc

steemit::chain::witness_schedule_object debug_node_api_impl::debug_get_witness_schedule()
{
return steemit::chain::witness_schedule_id_type()( *app.chain_database() );
return app.chain_database()->get( steemit::chain::witness_schedule_id_type() );
}

steemit::chain::hardfork_property_object debug_node_api_impl::debug_get_hardfork_property_object()
{
return steemit::chain::hardfork_property_id_type()( *app.chain_database() );
return app.chain_database()->get( steemit::chain::hardfork_property_id_type() );
}

void debug_node_api_impl::debug_update_object( const fc::variant_object& update )
Expand Down Expand Up @@ -290,8 +290,7 @@ void debug_node_api_impl::debug_set_hardfork( uint32_t hardfork_id )

bool debug_node_api_impl::debug_has_hardfork( uint32_t hardfork_id )
{
idump( (steemit::chain::hardfork_property_id_type()( *app.chain_database() ))(hardfork_id) );
return steemit::chain::hardfork_property_id_type()( *app.chain_database() ).last_hardfork >= hardfork_id;
return app.chain_database()->get( steemit::chain::hardfork_property_id_type() ).last_hardfork >= hardfork_id;
}

void debug_node_api_impl::debug_get_json_schema( std::string& schema )
Expand Down
8 changes: 4 additions & 4 deletions libraries/plugins/follow/follow_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ vector< feed_entry > follow_api_impl::get_feed_entries( string account, uint32_t

while( itr != feed_idx.end() && itr->account == account && results.size() < limit )
{
const auto& comment = itr->comment( db );
const auto& comment = db.get( itr->comment );
feed_entry entry;
entry.author = comment.author;
entry.permlink = to_string( comment.permlink );
Expand Down Expand Up @@ -148,7 +148,7 @@ vector< comment_feed_entry > follow_api_impl::get_feed( string account, uint32_t

while( itr != feed_idx.end() && itr->account == account && results.size() < limit )
{
const auto& comment = itr->comment( db );
const auto& comment = db.get( itr->comment );
comment_feed_entry entry;
entry.comment = comment;
entry.entry_id = itr->account_feed_id;
Expand Down Expand Up @@ -181,7 +181,7 @@ vector< blog_entry > follow_api_impl::get_blog_entries( string account, uint32_t

while( itr != blog_idx.end() && itr->account == account && results.size() < limit )
{
const auto& comment = itr->comment( db );
const auto& comment = db.get( itr->comment );
blog_entry entry;
entry.author = comment.author;
entry.permlink = to_string( comment.permlink );
Expand Down Expand Up @@ -213,7 +213,7 @@ vector< comment_blog_entry > follow_api_impl::get_blog( string account, uint32_t

while( itr != blog_idx.end() && itr->account == account && results.size() < limit )
{
const auto& comment = itr->comment( db );
const auto& comment = db.get( itr->comment );
comment_blog_entry entry;
entry.comment = comment;
entry.blog = account;
Expand Down
4 changes: 2 additions & 2 deletions tests/common/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void database_fixture::set_price_feed( const price& new_price )
#ifdef IS_TEST_NET
!db.skip_price_feed_limit_check ||
#endif
feed_history_id_type()( db ).current_median_history == new_price
db.get(feed_history_id_type()).current_median_history == new_price
);
}

Expand All @@ -493,7 +493,7 @@ vector< operation > database_fixture::get_last_operations( uint32_t num_ops )
while( itr != acc_hist_idx.begin() && ops.size() < num_ops )
{
itr--;
ops.push_back( fc::raw::unpack< steemit::chain::operation >( itr->op(db).serialized_op ) );
ops.push_back( fc::raw::unpack< steemit::chain::operation >( db.get(itr->op).serialized_op ) );
}

return ops;
Expand Down
Loading

0 comments on commit 4f197c6

Please sign in to comment.