Passing a shared_ptr to block callback.

This commit is contained in:
clemahieu 2017-08-30 18:21:26 -05:00
commit 78b25b0ae4
5 changed files with 9 additions and 9 deletions

View file

@ -1004,10 +1004,10 @@ TEST (node, coherent_observer)
{
rai::system system (24000, 1);
auto & node1 (*system.nodes [0]);
node1.observers.blocks.add ([&node1] (rai::block const & block_a, rai::account const & account_a, rai::amount const &)
node1.observers.blocks.add ([&node1] (std::shared_ptr <rai::block> block_a, rai::account const & account_a, rai::amount const &)
{
rai::transaction transaction (node1.store.environment, nullptr, false);
ASSERT_TRUE (node1.store.block_exists (transaction, block_a.hash ()));
ASSERT_TRUE (node1.store.block_exists (transaction, block_a->hash ()));
});
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
rai::keypair key;

View file

@ -1305,15 +1305,15 @@ block_processor (*this)
{
observers.disconnect ();
};
observers.blocks.add ([this] (rai::block const & block_a, rai::account const & account_a, rai::amount const & amount_a)
observers.blocks.add ([this] (std::shared_ptr <rai::block> block_a, rai::account const & account_a, rai::amount const & amount_a)
{
if (!config.callback_address.empty ())
{
boost::property_tree::ptree event;
event.add ("account", account_a.to_account ());
event.add ("hash", block_a.hash ().to_string ());
event.add ("hash", block_a->hash ().to_string ());
std::string block_text;
block_a.serialize_json (block_text);
block_a->serialize_json (block_text);
event.add ("block", block_text);
event.add ("amount", amount_a.to_string_dec ());
std::stringstream ostream;
@ -1584,7 +1584,7 @@ void rai::node::process_receive_republish (std::shared_ptr <rai::block> incoming
node_l->active.start (transaction_a, block_a);
node_l->background ([node_l, block_a, result_a] ()
{
node_l->observers.blocks (*block_a, result_a.account, result_a.amount);
node_l->observers.blocks (block_a, result_a.account, result_a.amount);
});
break;
}

View file

@ -382,7 +382,7 @@ public:
class node_observers
{
public:
rai::observer_set <rai::block const &, rai::account const &, rai::amount const &> blocks;
rai::observer_set <std::shared_ptr <rai::block>, rai::account const &, rai::amount const &> blocks;
rai::observer_set <rai::account const &, bool> wallet;
rai::observer_set <rai::vote const &, rai::endpoint const &> vote;
rai::observer_set <rai::endpoint const &> endpoint;

View file

@ -77,7 +77,7 @@ node (node_a)
acceptor.set_option (boost::asio::ip::tcp::acceptor::reuse_address (true));
acceptor.bind (endpoint);
acceptor.listen ();
node_a.observers.blocks.add ([this] (rai::block const & block_a, rai::account const & account_a, rai::amount const &)
node_a.observers.blocks.add ([this] (std::shared_ptr <rai::block> block_a, rai::account const & account_a, rai::amount const &)
{
observer_action (account_a);
});

View file

@ -996,7 +996,7 @@ void rai_qt::wallet::start ()
this_l->push_main_stack (this_l->send_blocks_window);
}
});
node.observers.blocks.add ([this_w] (rai::block const &, rai::account const & account_a, rai::amount const &)
node.observers.blocks.add ([this_w] (std::shared_ptr <rai::block>, rai::account const & account_a, rai::amount const &)
{
if (auto this_l = this_w.lock ())
{