Fix whitespace
This commit is contained in:
parent
2212cfe95b
commit
2244e467ed
3 changed files with 51 additions and 47 deletions
|
|
@ -85,10 +85,10 @@ bool database::push_block(const signed_block& new_block, uint32_t skip)
|
|||
{
|
||||
|
||||
bool result;
|
||||
with_skip_flags( skip, [&]()
|
||||
with_skip_flags(skip, [&]()
|
||||
{
|
||||
result = _push_block( new_block );
|
||||
} );
|
||||
result = _push_block(new_block);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ signed_block database::_generate_block(
|
|||
_pending_block.transactions.clear();
|
||||
|
||||
bool failed = false;
|
||||
try { push_block( tmp, skip ); }
|
||||
try { push_block( tmp, skip ); }
|
||||
catch ( const undo_database_exception& e ) { throw; }
|
||||
catch ( const fc::exception& e ) { failed = true; }
|
||||
if( failed )
|
||||
|
|
@ -443,7 +443,7 @@ void database::notify_changed_objects()
|
|||
for( const auto& item : head_undo.new_ids ) changed_ids.push_back(item);
|
||||
vector<const object*> removed;
|
||||
removed.reserve( head_undo.removed.size() );
|
||||
for( const auto& item : head_undo.removed )
|
||||
for( const auto& item : head_undo.removed )
|
||||
{
|
||||
changed_ids.push_back( item.first );
|
||||
removed.emplace_back( item.second.get() );
|
||||
|
|
@ -491,12 +491,12 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
|||
|
||||
//Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration
|
||||
FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FC_ASSERT( trx.expiration <= _pending_block.timestamp + chain_parameters.maximum_time_until_expiration, "",
|
||||
("trx.expiration",trx.expiration)("_pending_block.timestamp",_pending_block.timestamp)("max_til_exp",chain_parameters.maximum_time_until_expiration));
|
||||
FC_ASSERT( _pending_block.timestamp <= trx.expiration, "", ("pending.timestamp",_pending_block.timestamp)("trx.exp",trx.expiration) );
|
||||
}
|
||||
}
|
||||
|
||||
//Insert transaction into unique transactions database.
|
||||
if( !(skip & skip_transaction_dupe_check) )
|
||||
|
|
|
|||
|
|
@ -34,48 +34,48 @@ void fork_database::pop_block()
|
|||
if( _head ) _head = _head->prev.lock();
|
||||
}
|
||||
|
||||
void fork_database::start_block( signed_block b )
|
||||
void fork_database::start_block(signed_block b)
|
||||
{
|
||||
auto item = std::make_shared<fork_item>( std::move(b) );
|
||||
_index.insert( item );
|
||||
auto item = std::make_shared<fork_item>(std::move(b));
|
||||
_index.insert(item);
|
||||
_head = item;
|
||||
}
|
||||
|
||||
shared_ptr<fork_item> fork_database::push_block( const signed_block& b )
|
||||
shared_ptr<fork_item> fork_database::push_block(const signed_block& b)
|
||||
{
|
||||
auto item = std::make_shared<fork_item>( b );
|
||||
auto item = std::make_shared<fork_item>(b);
|
||||
|
||||
if( _head && b.previous != block_id_type() )
|
||||
{
|
||||
auto itr = _index.get<block_id>().find( b.previous );
|
||||
FC_ASSERT( itr != _index.get<block_id>().end() );
|
||||
FC_ASSERT( !(*itr)->invalid );
|
||||
auto itr = _index.get<block_id>().find(b.previous);
|
||||
FC_ASSERT(itr != _index.get<block_id>().end());
|
||||
FC_ASSERT(!(*itr)->invalid);
|
||||
item->prev = *itr;
|
||||
}
|
||||
|
||||
_index.insert( item );
|
||||
_index.insert(item);
|
||||
if( !_head ) _head = item;
|
||||
else if( item->num > _head->num )
|
||||
{
|
||||
_head = item;
|
||||
_index.get<block_num>().erase( _head->num - 1024 );
|
||||
_index.get<block_num>().erase(_head->num - 1024);
|
||||
}
|
||||
return _head;
|
||||
}
|
||||
bool fork_database::is_known_block( const block_id_type& id )const
|
||||
bool fork_database::is_known_block(const block_id_type& id)const
|
||||
{
|
||||
auto& index = _index.get<block_id>();
|
||||
auto itr = index.find(id);
|
||||
return itr != index.end();
|
||||
}
|
||||
item_ptr fork_database::fetch_block( const block_id_type& id )const
|
||||
item_ptr fork_database::fetch_block(const block_id_type& id)const
|
||||
{
|
||||
auto itr = _index.get<block_id>().find(id);
|
||||
if( itr != _index.get<block_id>().end() )
|
||||
return *itr;
|
||||
return item_ptr();
|
||||
}
|
||||
vector<item_ptr> fork_database::fetch_block_by_number( uint32_t num )const
|
||||
vector<item_ptr> fork_database::fetch_block_by_number(uint32_t num)const
|
||||
{
|
||||
vector<item_ptr> result;
|
||||
auto itr = _index.get<block_num>().find(num);
|
||||
|
|
@ -91,48 +91,53 @@ vector<item_ptr> fork_database::fetch_block_by_number( uint32_t num )const
|
|||
}
|
||||
|
||||
pair<fork_database::branch_type,fork_database::branch_type>
|
||||
fork_database::fetch_branch_from( block_id_type first, block_id_type second )const
|
||||
fork_database::fetch_branch_from(block_id_type first, block_id_type second)const
|
||||
{ try {
|
||||
pair<branch_type,branch_type> result;
|
||||
auto first_branch_itr = _index.get<block_id>().find(first);
|
||||
FC_ASSERT( first_branch_itr != _index.get<block_id>().end() );
|
||||
FC_ASSERT(first_branch_itr != _index.get<block_id>().end());
|
||||
auto first_branch = *first_branch_itr;
|
||||
|
||||
auto second_branch_itr = _index.get<block_id>().find(second);
|
||||
FC_ASSERT( second_branch_itr != _index.get<block_id>().end() );
|
||||
FC_ASSERT(second_branch_itr != _index.get<block_id>().end());
|
||||
auto second_branch = *second_branch_itr;
|
||||
|
||||
|
||||
while( first_branch->data.block_num() > second_branch->data.block_num() )
|
||||
{
|
||||
result.first.push_back( first_branch );
|
||||
first_branch = first_branch->prev.lock(); FC_ASSERT( first_branch );
|
||||
result.first.push_back(first_branch);
|
||||
first_branch = first_branch->prev.lock();
|
||||
FC_ASSERT(first_branch);
|
||||
}
|
||||
while( second_branch->data.block_num() > first_branch->data.block_num() )
|
||||
{
|
||||
result.second.push_back( second_branch );
|
||||
second_branch = second_branch->prev.lock(); FC_ASSERT( second_branch );
|
||||
second_branch = second_branch->prev.lock();
|
||||
FC_ASSERT(second_branch);
|
||||
}
|
||||
while( first_branch->data.previous != second_branch->data.previous )
|
||||
{
|
||||
result.first.push_back( first_branch );
|
||||
result.second.push_back( second_branch );
|
||||
first_branch = first_branch->prev.lock(); FC_ASSERT( first_branch );
|
||||
second_branch = second_branch->prev.lock(); FC_ASSERT( second_branch );
|
||||
result.first.push_back(first_branch);
|
||||
result.second.push_back(second_branch);
|
||||
first_branch = first_branch->prev.lock();
|
||||
FC_ASSERT(first_branch);
|
||||
second_branch = second_branch->prev.lock();
|
||||
FC_ASSERT(second_branch);
|
||||
}
|
||||
if( first_branch && second_branch )
|
||||
{
|
||||
result.first.push_back( first_branch );
|
||||
result.second.push_back( second_branch );
|
||||
result.first.push_back(first_branch);
|
||||
result.second.push_back(second_branch);
|
||||
}
|
||||
return result;
|
||||
} FC_CAPTURE_AND_RETHROW( (first)(second) ) }
|
||||
void fork_database::set_head( shared_ptr<fork_item> h )
|
||||
|
||||
void fork_database::set_head(shared_ptr<fork_item> h)
|
||||
{
|
||||
_head = h;
|
||||
}
|
||||
|
||||
void fork_database::remove( block_id_type id )
|
||||
void fork_database::remove(block_id_type id)
|
||||
{
|
||||
_index.get<block_id>().erase(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,31 +62,30 @@ namespace graphene { namespace chain {
|
|||
fork_database();
|
||||
void reset();
|
||||
|
||||
void start_block( signed_block b );
|
||||
void remove( block_id_type b );
|
||||
void set_head( shared_ptr<fork_item> h );
|
||||
bool is_known_block( const block_id_type& id )const;
|
||||
shared_ptr<fork_item> fetch_block( const block_id_type& id )const;
|
||||
vector<item_ptr> fetch_block_by_number( uint32_t n )const;
|
||||
shared_ptr<fork_item> push_block(const signed_block& b );
|
||||
void start_block(signed_block b);
|
||||
void remove(block_id_type b);
|
||||
void set_head(shared_ptr<fork_item> h);
|
||||
bool is_known_block(const block_id_type& id)const;
|
||||
shared_ptr<fork_item> fetch_block(const block_id_type& id)const;
|
||||
vector<item_ptr> fetch_block_by_number(uint32_t n)const;
|
||||
shared_ptr<fork_item> push_block(const signed_block& b);
|
||||
shared_ptr<fork_item> head()const { return _head; }
|
||||
void pop_block();
|
||||
|
||||
|
||||
/**
|
||||
* Given two head blocks, return two branches of the fork graph that
|
||||
* end with a common ancestor (same prior block)
|
||||
*/
|
||||
pair< branch_type, branch_type > fetch_branch_from( block_id_type first,
|
||||
block_id_type second )const;
|
||||
pair< branch_type, branch_type > fetch_branch_from(block_id_type first,
|
||||
block_id_type second)const;
|
||||
|
||||
struct block_id;
|
||||
struct block_num;
|
||||
typedef multi_index_container<
|
||||
item_ptr,
|
||||
indexed_by<
|
||||
hashed_unique< tag<block_id>, member< fork_item, block_id_type, &fork_item::id>, std::hash<fc::ripemd160> >,
|
||||
ordered_non_unique< tag<block_num>, member<fork_item,uint32_t,&fork_item::num> >
|
||||
hashed_unique<tag<block_id>, member<fork_item, block_id_type, &fork_item::id>, std::hash<fc::ripemd160>>,
|
||||
ordered_non_unique<tag<block_num>, member<fork_item,uint32_t,&fork_item::num>>
|
||||
>
|
||||
> fork_multi_index_type;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue