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/zmqpublishnotifier.h | |
parent | 8ed4ff8e05d61a8e954d72cebdc2e1d1ab24fb84 (diff) | |
download | bitcoin-cfbb2124939822e95265a39242ffca3d86bac6e8.tar.xz |
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/zmqpublishnotifier.h')
-rw-r--r-- | src/zmq/zmqpublishnotifier.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h index 18336a5eb0..a5cd433761 100644 --- a/src/zmq/zmqpublishnotifier.h +++ b/src/zmq/zmqpublishnotifier.h @@ -9,7 +9,9 @@ #include <cstddef> #include <cstdint> +#include <functional> +class CBlock; class CBlockIndex; class CTransaction; @@ -46,7 +48,12 @@ public: class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier { +private: + const std::function<bool(CBlock&, const CBlockIndex&)> m_get_block_by_index; + public: + CZMQPublishRawBlockNotifier(std::function<bool(CBlock&, const CBlockIndex&)> get_block_by_index) + : m_get_block_by_index{std::move(get_block_by_index)} {} bool NotifyBlock(const CBlockIndex *pindex) override; }; |