fork_database.cpp: Update is_known_block and fetch_block to also look in unlinked_index
This commit is contained in:
parent
32b18f6c20
commit
a5850bdb91
1 changed files with 14 additions and 6 deletions
|
|
@ -143,22 +143,30 @@ void fork_database::set_max_size( uint32_t s )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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& index = _index.get<block_id>();
|
||||||
auto itr = index.find(id);
|
auto itr = index.find(id);
|
||||||
return itr != index.end();
|
if( itr != index.end() )
|
||||||
|
return true;
|
||||||
|
auto& unlinked_index = _unlinked_index.get<block_id>();
|
||||||
|
auto unlinked_itr = unlinked_index.find(id);
|
||||||
|
return unlinked_itr != unlinked_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);
|
auto& index = _index.get<block_id>();
|
||||||
if( itr != _index.get<block_id>().end() )
|
auto itr = index.find(id);
|
||||||
|
if( itr != index.end() )
|
||||||
return *itr;
|
return *itr;
|
||||||
|
auto& unlinked_index = _unlinked_index.get<block_id>();
|
||||||
|
auto unlinked_itr = unlinked_index.find(id);
|
||||||
|
if( unlinked_itr != unlinked_index.end() )
|
||||||
|
return *unlinked_itr;
|
||||||
return item_ptr();
|
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;
|
vector<item_ptr> result;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue