Skip to content

Commit

Permalink
Merge branch '177-new-cashout-times' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed Jul 21, 2016
2 parents 2558ec3 + ccb9f4d commit 222e1de
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 19 additions & 6 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3523,14 +3523,27 @@ void database::apply_hardfork( uint32_t hardfork )

for( auto itr = comment_idx.begin(); itr != comment_idx.end(); ++itr )
{
// At the hardfork time, all paid comments are still within their 30 day second cashout window.
// If it has been paid, set the second cashout time.
if( itr->parent_author.size() == 0 && itr->last_payout > fc::time_point_sec() )
// At the hardfork time, all new posts with no votes get their cashout time set to +12 hrs from head block time.
// All posts with a payout get their cashout time set to +30 days. This hardfork takes place within 30 days
// initial payout so we don't have to handle the case of posts that should be frozen that aren't
if( itr->parent_author.size() == 0 )
{
modify( *itr, [&]( comment_object& c )
// Post has not been paid out and has no votes (cashout_time == 0 === net_rshares == 0, under current semmantics)
if( itr->last_payout == fc::time_point_sec::min() && itr->cashout_time == fc::time_point_sec::maximum() )
{
c.cashout_time = c.last_payout + STEEMIT_SECOND_CASHOUT_WINDOW;
});
modify( *itr, [&]( comment_object & c )
{
c.cashout_time = head_block_time() + STEEMIT_CASHOUT_WINDOW_SECONDS;
});
}
// Has been paid out, needs to be on second cashout window
else if( itr->last_payout > fc::time_point_sec() )
{
modify( *itr, [&]( comment_object& c )
{
c.cashout_time = c.last_payout + STEEMIT_SECOND_CASHOUT_WINDOW;
});
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ void comment_evaluator::do_apply( const comment_operation& o )
{
const auto& comment = *itr;

if( db().has_hardfork( STEEMIT_HARDFORK_0_12__177 ) )
FC_ASSERT( db().calculate_discussion_payout_time( comment ) != fc::time_point_sec::maximum() );
else if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) )
if( db().has_hardfork( STEEMIT_HARDFORK_0_10 ) )
FC_ASSERT( comment.last_payout == fc::time_point_sec::min() );

db().modify( comment, [&]( comment_object& com )
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/operation_time_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,7 @@ BOOST_AUTO_TEST_CASE( comment_freeze )

tx.operations.push_back( comment );
tx.sign( alice_private_key, db.get_chain_id() );
db.push_transaction( tx, 0 );
STEEMIT_REQUIRE_THROW( db.push_transaction( tx, 0 ), fc::assert_exception );

generate_blocks( db.get_comment( "alice", "test" ).cashout_time, true );

Expand Down

0 comments on commit 222e1de

Please sign in to comment.