void object_database::open( const fc::path& data_dir )
{ try {
   ilog("Open object_database in ${d}", ("d", data_dir));

   _object_id_to_object->open( data_dir / "object_database" / "objects" );

   for( auto& space : _index )
   {
      for( auto& type_index : space )
      {
         if( type_index )
         {
            type_index->open( _object_id_to_object );
         }
      }
   }
   try {
   auto next_ids = fc::raw::unpack<vector<object_id_type>>( _object_id_to_object->fetch( object_id_type() ) );
   for( auto id : next_ids )
      get_mutable_index( id ).set_next_id( id );
   }
   catch ( const fc::exception& )
   {
      wlog( "unable to fetch next ids, must be new object_database" );
   }

   _data_dir = data_dir;
} FC_CAPTURE_AND_RETHROW( (data_dir) ) }
Example #2
0
void database::clear_expired_transactions()
{
   //Look for expired transactions in the deduplication list, and remove them.
   //Transactions must have expired by at least two forking windows in order to be removed.
   auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids, impl_transaction_object_type));
   const auto& dedupe_index = transaction_idx.indices().get<by_expiration>();
   while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.rbegin()->trx.expiration) )
      transaction_idx.remove(*dedupe_index.rbegin());
}
Example #3
0
 void modify( const T& obj, const Lambda& m ) {
    get_mutable_index(obj.id).modify(obj,m);
 }
Example #4
0
 void          remove( const object& obj ) { get_mutable_index(obj.id).remove( obj ); }
Example #5
0
 const object& insert( object&& obj ) { return get_mutable_index(obj.id).insert( std::move(obj) ); }
Example #6
0
 index& get_mutable_index(object_id_type id)  { return get_mutable_index(id.space(),id.type());   }
Example #7
0
 index& get_mutable_index()                   { return get_mutable_index(T::space_id,T::type_id); }
Example #8
0
 IndexType&    get_mutable_index_type() {
    static_assert( std::is_base_of<index,IndexType>::value, "Type must be an index type" );
    return static_cast<IndexType&>( get_mutable_index( IndexType::object_type::space_id, IndexType::object_type::type_id ) );
 }