Skip to content

Commit

Permalink
Wiring the 'batch_processed' observer directly to the 'processed'
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 4, 2023
1 parent a712e44 commit 725c8b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ nano::block_processor::block_processor (nano::node & node_a, nano::write_databas
write_database_queue (write_database_queue_a),
state_block_signature_verification (node.checker, node.ledger.constants.epochs, node.config, node.logger, node.flags.block_processor_verification_size)
{
batch_processed.add ([this] (auto const & items) {
// For every batch item: notify the 'processed' observer.
auto tx = node.store.tx_begin_read ();
for (auto const & item : items)
{
auto const & [result, block] = item;
processed.notify (tx, result, *block);
}
});
blocking.connect (*this);
state_block_signature_verification.blocks_verified_callback = [this] (std::deque<nano::state_block_signature_verification::value_type> & items, std::vector<int> const & verifications, std::vector<nano::block_hash> const & hashes, std::vector<nano::signature> const & blocks_signatures) {
this->process_verified_state_blocks (items, verifications, hashes, blocks_signatures);
Expand Down Expand Up @@ -334,9 +343,6 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
nano::process_return result;
auto hash (block->hash ());
result = node.ledger.process (transaction_a, *block);
events_a.events.emplace_back ([this, result, block] (nano::transaction const & tx) {
processed.notify (tx, result, *block);
});
switch (result.code)
{
case nano::process_result::progress:
Expand Down
2 changes: 2 additions & 0 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class block_processor final
public: // Events
using processed_t = std::pair<nano::process_return, std::shared_ptr<nano::block>>;
nano::observer_set<nano::transaction const &, nano::process_return const &, nano::block const &> processed;

// The batch observer feeds the processed obsever
nano::observer_set<std::deque<processed_t> const &> batch_processed;

private:
Expand Down

0 comments on commit 725c8b3

Please sign in to comment.