notify observes of changed objects after every pushed transaction
This commit is contained in:
parent
962310b415
commit
d7f7d64352
2 changed files with 11 additions and 5 deletions
|
|
@ -202,6 +202,7 @@ processed_transaction database::_push_transaction( const signed_transaction& trx
|
||||||
FC_ASSERT( (skip & skip_block_size_check) ||
|
FC_ASSERT( (skip & skip_block_size_check) ||
|
||||||
fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size );
|
fc::raw::pack_size(_pending_block) <= get_global_properties().parameters.maximum_block_size );
|
||||||
|
|
||||||
|
notify_changed_objects();
|
||||||
// The transaction applied successfully. Merge its changes into the pending block session.
|
// The transaction applied successfully. Merge its changes into the pending block session.
|
||||||
session.merge();
|
session.merge();
|
||||||
return processed_trx;
|
return processed_trx;
|
||||||
|
|
@ -397,14 +398,18 @@ void database::_apply_block( const signed_block& next_block )
|
||||||
applied_block( next_block ); //emit
|
applied_block( next_block ); //emit
|
||||||
_applied_ops.clear();
|
_applied_ops.clear();
|
||||||
|
|
||||||
|
notify_changed_objects();
|
||||||
|
|
||||||
|
update_pending_block(next_block, current_block_interval);
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (next_block.block_num()) ) }
|
||||||
|
|
||||||
|
void database::notify_changed_objects()
|
||||||
|
{
|
||||||
const auto& head_undo = _undo_db.head();
|
const auto& head_undo = _undo_db.head();
|
||||||
vector<object_id_type> changed_ids; changed_ids.reserve(head_undo.old_values.size());
|
vector<object_id_type> changed_ids; changed_ids.reserve(head_undo.old_values.size());
|
||||||
for( const auto& item : head_undo.old_values ) changed_ids.push_back(item.first);
|
for( const auto& item : head_undo.old_values ) changed_ids.push_back(item.first);
|
||||||
changed_objects(changed_ids);
|
changed_objects(changed_ids);
|
||||||
|
}
|
||||||
|
|
||||||
update_pending_block(next_block, current_block_interval);
|
|
||||||
} FC_CAPTURE_AND_RETHROW( (next_block.block_num()) ) }
|
|
||||||
|
|
||||||
processed_transaction database::apply_transaction( const signed_transaction& trx, uint32_t skip )
|
processed_transaction database::apply_transaction( const signed_transaction& trx, uint32_t skip )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ namespace graphene { namespace chain {
|
||||||
fc::signal<void(const signed_block&)> applied_block;
|
fc::signal<void(const signed_block&)> applied_block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After a block has been applied and committed. The callback
|
* Emitted After a block has been applied and committed. The callback
|
||||||
* should not yield and should execute quickly.
|
* should not yield and should execute quickly.
|
||||||
*/
|
*/
|
||||||
fc::signal<void(const vector<object_id_type>&)> changed_objects;
|
fc::signal<void(const vector<object_id_type>&)> changed_objects;
|
||||||
|
|
@ -394,6 +394,7 @@ namespace graphene { namespace chain {
|
||||||
protected:
|
protected:
|
||||||
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
|
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
|
||||||
void pop_undo() { object_database::pop_undo(); }
|
void pop_undo() { object_database::pop_undo(); }
|
||||||
|
void notify_changed_objects();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
optional<undo_database::session> _pending_block_session;
|
optional<undo_database::session> _pending_block_session;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue