Skip to content

Commit

Permalink
Address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconrad committed Nov 7, 2018
1 parent e6853cc commit 81f7520
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,7 @@ fc::future<void> database::precompute_parallel( const signed_block& block, const
else
{
uint32_t chunks = fc::asio::default_io_service_scope::get_num_threads();
uint32_t chunk_size = block.transactions.size() / chunks;
if( chunks * chunk_size < block.transactions.size() )
chunk_size++;
uint32_t chunk_size = ( block.transactions.size() + chunks - 1 ) / chunks;
workers.reserve( chunks + 1 );
for( size_t base = 0; base < block.transactions.size(); base += chunk_size )
workers.push_back( fc::do_parallel( [this,&block,base,chunk_size,skip] () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ namespace graphene { namespace chain {
digest_type digest()const;
virtual const transaction_id_type& id()const;
virtual void validate() const;
/// Calculate the digest used for signature validation

void set_expiration( fc::time_point_sec expiration_time );
void set_reference_block( const block_id_type& reference_block );
Expand All @@ -115,6 +114,7 @@ namespace graphene { namespace chain {
void get_required_authorities( flat_set<account_id_type>& active, flat_set<account_id_type>& owner, vector<authority>& other )const;

protected:
// Calculate the digest used for signature validation
digest_type sig_digest( const chain_id_type& chain_id )const;
mutable transaction_id_type _tx_id_buffer;
};
Expand Down Expand Up @@ -206,9 +206,9 @@ namespace graphene { namespace chain {
precomputable_transaction( const signed_transaction& tx ) : signed_transaction(tx) {};
precomputable_transaction( signed_transaction&& tx ) : signed_transaction( std::move(tx) ) {};

virtual const transaction_id_type& id()const;
virtual void validate() const;
virtual const flat_set<public_key_type>& get_signature_keys( const chain_id_type& chain_id )const;
virtual const transaction_id_type& id()const override;
virtual void validate()const override;
virtual const flat_set<public_key_type>& get_signature_keys( const chain_id_type& chain_id )const override;
protected:
mutable bool _validated = false;
};
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/protocol/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ void verify_authority( const vector<operation>& ops, const flat_set<public_key_t

const flat_set<public_key_type>& signed_transaction::get_signature_keys( const chain_id_type& chain_id )const
{ try {
// Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field.
// However, we don't pass in another chain ID so far, for better performance, we skip the check.
auto d = sig_digest( chain_id );
flat_set<public_key_type> result;
for( const auto& sig : signatures )
Expand Down Expand Up @@ -397,6 +395,8 @@ void precomputable_transaction::validate() const

const flat_set<public_key_type>& precomputable_transaction::get_signature_keys( const chain_id_type& chain_id )const
{
// Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field.
// However, we don't pass in another chain ID so far, for better performance, we skip the check.
if( _signees.empty() )
signed_transaction::get_signature_keys( chain_id );
return _signees;
Expand Down
1 change: 1 addition & 0 deletions libraries/plugins/delayed_node/delayed_node_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void delayed_node_plugin::sync_with_trusted_node()
while( remote_dpo.last_irreversible_block_num > db.head_block_num() )
{
fc::optional<graphene::chain::signed_block> block = my->database_api->get_block( db.head_block_num()+1 );
// TODO: during sync, decouple requesting blocks from preprocessing + applying them
FC_ASSERT(block, "Trusted node claims it has blocks it doesn't actually have.");
ilog("Pushing block #${n}", ("n", block->block_num()));
db.precompute_parallel( *block, graphene::chain::database::skip_nothing ).wait();
Expand Down
1 change: 1 addition & 0 deletions tests/common/database_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ namespace graphene { namespace chain {

class clearable_block : public signed_block {
public:
/** @brief Clears internal cached values like ID, signing key, Merkle root etc. */
void clear();
};

Expand Down

0 comments on commit 81f7520

Please sign in to comment.