diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-05-03 22:24:21 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-05-10 19:06:45 +0200 |
commit | cfbb2124939822e95265a39242ffca3d86bac6e8 (patch) | |
tree | 259f3096ef432bb3a52d9de21331928e42a8eaf0 /src/zmq/zmqnotificationinterface.cpp | |
parent | 8ed4ff8e05d61a8e954d72cebdc2e1d1ab24fb84 (diff) |
zmq: Pass lambda to zmq's ZMQPublishRawBlockNotifier
The lambda captures a reference to the chainman unique_ptr to retrieve
block data. An assert is added on the chainman to ensure that the lambda
is not used while the chainman is uninitialized.
This is done in preparation for the following commits where blockstorage
functions are made BlockManager methods.
Diffstat (limited to 'src/zmq/zmqnotificationinterface.cpp')
-rw-r--r-- | src/zmq/zmqnotificationinterface.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 2ed0c93fc3..6755368249 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -39,12 +39,14 @@ std::list<const CZMQAbstractNotifier*> CZMQNotificationInterface::GetActiveNotif return result; } -std::unique_ptr<CZMQNotificationInterface> CZMQNotificationInterface::Create() +std::unique_ptr<CZMQNotificationInterface> CZMQNotificationInterface::Create(std::function<bool(CBlock&, const CBlockIndex&)> get_block_by_index) { std::map<std::string, CZMQNotifierFactory> factories; factories["pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>; factories["pubhashtx"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionNotifier>; - factories["pubrawblock"] = CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>; + factories["pubrawblock"] = [&get_block_by_index]() -> std::unique_ptr<CZMQAbstractNotifier> { + return std::make_unique<CZMQPublishRawBlockNotifier>(get_block_by_index); + }; factories["pubrawtx"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>; factories["pubsequence"] = CZMQAbstractNotifier::Create<CZMQPublishSequenceNotifier>; |