Fix #158 - block summary database now only has 2^16 entries
This commit is contained in:
parent
b9f6ee4f2c
commit
da254cdbff
4 changed files with 15 additions and 4 deletions
|
|
@ -41,7 +41,7 @@ struct predicate_evaluator
|
||||||
}
|
}
|
||||||
void operator()( const block_id_predicate& p )const
|
void operator()( const block_id_predicate& p )const
|
||||||
{
|
{
|
||||||
FC_ASSERT( block_summary_id_type( block_header::num_from_id( p.id ) )(db).block_id == p.id );
|
FC_ASSERT( block_summary_id_type( block_header::num_from_id( p.id ) & 0xffff )(db).block_id == p.id );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -524,6 +524,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
||||||
// integer that satisfies (a) and (b); for x1, the next
|
// integer that satisfies (a) and (b); for x1, the next
|
||||||
// largest integer that satisfies (a), does not satisfy (b).
|
// largest integer that satisfies (a), does not satisfy (b).
|
||||||
//
|
//
|
||||||
|
/**
|
||||||
int64_t N = head_block_num();
|
int64_t N = head_block_num();
|
||||||
int64_t a = N & 0xFFFF;
|
int64_t a = N & 0xFFFF;
|
||||||
int64_t r = trx.ref_block_num;
|
int64_t r = trx.ref_block_num;
|
||||||
|
|
@ -546,8 +547,9 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
||||||
{
|
{
|
||||||
ref_block_height = uint32_t( x0 );
|
ref_block_height = uint32_t( x0 );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
const auto& tapos_block_summary = block_summary_id_type( ref_block_height )(*this);
|
const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this);
|
||||||
|
|
||||||
//This is the signature check for transactions with relative expiration.
|
//This is the signature check for transactions with relative expiration.
|
||||||
if( !(skip & skip_transaction_signatures) )
|
if( !(skip & skip_transaction_signatures) )
|
||||||
|
|
@ -652,11 +654,11 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
|
||||||
|
|
||||||
void database::create_block_summary(const signed_block& next_block)
|
void database::create_block_summary(const signed_block& next_block)
|
||||||
{
|
{
|
||||||
const auto& sum = create<block_summary_object>( [&](block_summary_object& p) {
|
block_summary_id_type sid(next_block.block_num() & 0xffff );
|
||||||
|
modify( sid(*this), [&](block_summary_object& p) {
|
||||||
p.block_id = next_block.id();
|
p.block_id = next_block.id();
|
||||||
p.timestamp = next_block.timestamp;
|
p.timestamp = next_block.timestamp;
|
||||||
});
|
});
|
||||||
FC_ASSERT( sum.id.instance() == next_block.block_num(), "", ("summary.id",sum.id)("next.block_num",next_block.block_num()) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void database::add_checkpoints( const flat_map<uint32_t,block_id_type>& checkpts )
|
void database::add_checkpoints( const flat_map<uint32_t,block_id_type>& checkpts )
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,9 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
|
|
||||||
transaction_evaluation_state genesis_eval_state(this);
|
transaction_evaluation_state genesis_eval_state(this);
|
||||||
|
|
||||||
|
flat_index<block_summary_object>& bsi = get_mutable_index_type< flat_index<block_summary_object> >();
|
||||||
|
bsi.resize(0xffff+1);
|
||||||
|
|
||||||
// Create blockchain accounts
|
// Create blockchain accounts
|
||||||
fc::ecc::private_key null_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
fc::ecc::private_key null_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")));
|
||||||
create<account_balance_object>([](account_balance_object& b) {
|
create<account_balance_object>([](account_balance_object& b) {
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,12 @@ namespace graphene { namespace db {
|
||||||
|
|
||||||
size_t size()const{ return _objects.size(); }
|
size_t size()const{ return _objects.size(); }
|
||||||
|
|
||||||
|
void resize( uint32_t s ) {
|
||||||
|
_objects.resize(s);
|
||||||
|
for( uint32_t i = 0; i < s; ++i )
|
||||||
|
_objects[i].id = object_id_type(object_type::space_id,object_type::type_id,i);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector< T > _objects;
|
vector< T > _objects;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue