adding API callback for observing pending transactions
This commit is contained in:
parent
9080800c5b
commit
a748883fed
4 changed files with 17 additions and 0 deletions
|
|
@ -45,6 +45,10 @@ namespace graphene { namespace app {
|
||||||
on_objects_removed(objs);
|
on_objects_removed(objs);
|
||||||
});
|
});
|
||||||
_applied_block_connection = _db.applied_block.connect([this](const signed_block&){ on_applied_block(); });
|
_applied_block_connection = _db.applied_block.connect([this](const signed_block&){ on_applied_block(); });
|
||||||
|
|
||||||
|
_pending_trx_connection = _db.on_pending_transaction.connect([this](const signed_transaction& trx ){
|
||||||
|
if( _pending_trx_callback ) _pending_trx_callback( fc::variant(trx) );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
database_api::~database_api()
|
database_api::~database_api()
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,7 @@ namespace graphene { namespace app {
|
||||||
vector<asset> get_required_fees( const vector<operation>& ops, asset_id_type id = asset_id_type() )const;
|
vector<asset> get_required_fees( const vector<operation>& ops, asset_id_type id = asset_id_type() )const;
|
||||||
|
|
||||||
void set_subscribe_callback( std::function<void(const variant&)> cb, bool clear_filter );
|
void set_subscribe_callback( std::function<void(const variant&)> cb, bool clear_filter );
|
||||||
|
void set_pending_transaction_callback( std::function<void(const variant&)> cb ){ _pending_trx_callback = cb; }
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void subscribe_to_item( const T& i )const
|
void subscribe_to_item( const T& i )const
|
||||||
|
|
@ -396,10 +397,12 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
mutable fc::bloom_filter _subscribe_filter;
|
mutable fc::bloom_filter _subscribe_filter;
|
||||||
std::function<void(const fc::variant&)> _subscribe_callback;
|
std::function<void(const fc::variant&)> _subscribe_callback;
|
||||||
|
std::function<void(const fc::variant&)> _pending_trx_callback;
|
||||||
|
|
||||||
boost::signals2::scoped_connection _change_connection;
|
boost::signals2::scoped_connection _change_connection;
|
||||||
boost::signals2::scoped_connection _removed_connection;
|
boost::signals2::scoped_connection _removed_connection;
|
||||||
boost::signals2::scoped_connection _applied_block_connection;
|
boost::signals2::scoped_connection _applied_block_connection;
|
||||||
|
boost::signals2::scoped_connection _pending_trx_connection;
|
||||||
map< pair<asset_id_type,asset_id_type>, std::function<void(const variant&)> > _market_subscriptions;
|
map< pair<asset_id_type,asset_id_type>, std::function<void(const variant&)> > _market_subscriptions;
|
||||||
graphene::chain::database& _db;
|
graphene::chain::database& _db;
|
||||||
};
|
};
|
||||||
|
|
@ -602,6 +605,7 @@ FC_API(graphene::app::database_api,
|
||||||
(get_blinded_balances)
|
(get_blinded_balances)
|
||||||
(get_required_fees)
|
(get_required_fees)
|
||||||
(set_subscribe_callback)
|
(set_subscribe_callback)
|
||||||
|
(set_pending_transaction_callback)
|
||||||
(validate_transaction)
|
(validate_transaction)
|
||||||
)
|
)
|
||||||
FC_API(graphene::app::history_api,
|
FC_API(graphene::app::history_api,
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,9 @@ processed_transaction database::_push_transaction( const signed_transaction& trx
|
||||||
notify_changed_objects();
|
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();
|
||||||
|
|
||||||
|
// notify anyone listening to pending transactions
|
||||||
|
on_pending_transaction( trx );
|
||||||
return processed_trx;
|
return processed_trx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,12 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
fc::signal<void(const signed_block&)> applied_block;
|
fc::signal<void(const signed_block&)> applied_block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted any time a new transaction is added to the pending
|
||||||
|
* block state.
|
||||||
|
*/
|
||||||
|
fc::signal<void(const signed_transaction&)> on_pending_transaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted 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.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue