Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zmq
zmqabstractnotifier.h
Go to the documentation of this file.
1
// Copyright (c) 2015-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
6
#define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
7
8
#include <cstdint>
9
#include <functional>
10
#include <memory>
11
#include <string>
12
13
class
CBlockIndex
;
14
class
CTransaction
;
15
class
CZMQAbstractNotifier
;
16
17
using
CZMQNotifierFactory
= std::function<std::unique_ptr<CZMQAbstractNotifier>()>;
18
19
class
CZMQAbstractNotifier
20
{
21
public
:
22
static
const
int
DEFAULT_ZMQ_SNDHWM
{1000};
23
24
virtual
~CZMQAbstractNotifier
();
25
26
template
<
typename
T>
27
static
std::unique_ptr<CZMQAbstractNotifier>
Create
()
28
{
29
return
std::make_unique<T>();
30
}
31
32
std::string
GetType
()
const
{
return
type
; }
33
void
SetType
(
const
std::string &
t
) {
type
=
t
; }
34
std::string
GetAddress
()
const
{
return
address
; }
35
void
SetAddress
(
const
std::string &a) {
address
= a; }
36
int
GetOutboundMessageHighWaterMark
()
const
{
return
outbound_message_high_water_mark
; }
37
void
SetOutboundMessageHighWaterMark
(
const
int
sndhwm) {
38
if
(sndhwm >= 0) {
39
outbound_message_high_water_mark
= sndhwm;
40
}
41
}
42
43
virtual
bool
Initialize
(
void
*pcontext) = 0;
44
virtual
void
Shutdown
() = 0;
45
46
// Notifies of ConnectTip result, i.e., new active tip only
47
virtual
bool
NotifyBlock
(
const
CBlockIndex
*pindex);
48
// Notifies of every block connection
49
virtual
bool
NotifyBlockConnect
(
const
CBlockIndex
*pindex);
50
// Notifies of every block disconnection
51
virtual
bool
NotifyBlockDisconnect
(
const
CBlockIndex
*pindex);
52
// Notifies of every mempool acceptance
53
virtual
bool
NotifyTransactionAcceptance
(
const
CTransaction
&transaction, uint64_t mempool_sequence);
54
// Notifies of every mempool removal, except inclusion in blocks
55
virtual
bool
NotifyTransactionRemoval
(
const
CTransaction
&transaction, uint64_t mempool_sequence);
56
// Notifies of transactions added to mempool or appearing in blocks
57
virtual
bool
NotifyTransaction
(
const
CTransaction
&transaction);
58
59
protected
:
60
void
*
psocket
{
nullptr
};
61
std::string
type
;
62
std::string
address
;
63
int
outbound_message_high_water_mark
{
DEFAULT_ZMQ_SNDHWM
};
// aka SNDHWM
64
};
65
66
#endif
// BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition
chain.h:94
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition
transaction.h:281
CZMQAbstractNotifier
Definition
zmqabstractnotifier.h:20
CZMQAbstractNotifier::GetType
std::string GetType() const
Definition
zmqabstractnotifier.h:32
CZMQAbstractNotifier::Shutdown
virtual void Shutdown()=0
CZMQAbstractNotifier::~CZMQAbstractNotifier
virtual ~CZMQAbstractNotifier()
Definition
zmqabstractnotifier.cpp:11
CZMQAbstractNotifier::NotifyBlockConnect
virtual bool NotifyBlockConnect(const CBlockIndex *pindex)
Definition
zmqabstractnotifier.cpp:26
CZMQAbstractNotifier::DEFAULT_ZMQ_SNDHWM
static const int DEFAULT_ZMQ_SNDHWM
Definition
zmqabstractnotifier.h:22
CZMQAbstractNotifier::psocket
void * psocket
Definition
zmqabstractnotifier.h:60
CZMQAbstractNotifier::SetOutboundMessageHighWaterMark
void SetOutboundMessageHighWaterMark(const int sndhwm)
Definition
zmqabstractnotifier.h:37
CZMQAbstractNotifier::Create
static std::unique_ptr< CZMQAbstractNotifier > Create()
Definition
zmqabstractnotifier.h:27
CZMQAbstractNotifier::SetAddress
void SetAddress(const std::string &a)
Definition
zmqabstractnotifier.h:35
CZMQAbstractNotifier::address
std::string address
Definition
zmqabstractnotifier.h:62
CZMQAbstractNotifier::type
std::string type
Definition
zmqabstractnotifier.h:61
CZMQAbstractNotifier::NotifyTransactionRemoval
virtual bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence)
Definition
zmqabstractnotifier.cpp:41
CZMQAbstractNotifier::NotifyBlock
virtual bool NotifyBlock(const CBlockIndex *pindex)
Definition
zmqabstractnotifier.cpp:16
CZMQAbstractNotifier::Initialize
virtual bool Initialize(void *pcontext)=0
CZMQAbstractNotifier::NotifyTransaction
virtual bool NotifyTransaction(const CTransaction &transaction)
Definition
zmqabstractnotifier.cpp:21
CZMQAbstractNotifier::GetAddress
std::string GetAddress() const
Definition
zmqabstractnotifier.h:34
CZMQAbstractNotifier::NotifyBlockDisconnect
virtual bool NotifyBlockDisconnect(const CBlockIndex *pindex)
Definition
zmqabstractnotifier.cpp:31
CZMQAbstractNotifier::SetType
void SetType(const std::string &t)
Definition
zmqabstractnotifier.h:33
CZMQAbstractNotifier::GetOutboundMessageHighWaterMark
int GetOutboundMessageHighWaterMark() const
Definition
zmqabstractnotifier.h:36
CZMQAbstractNotifier::NotifyTransactionAcceptance
virtual bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence)
Definition
zmqabstractnotifier.cpp:36
CZMQAbstractNotifier::outbound_message_high_water_mark
int outbound_message_high_water_mark
Definition
zmqabstractnotifier.h:63
ByteUnit::t
@ t
Definition
strencodings.h:52
CZMQNotifierFactory
std::function< std::unique_ptr< CZMQAbstractNotifier >()> CZMQNotifierFactory
Definition
zmqabstractnotifier.h:17
Generated on
for Bitcoin Core by
1.17.0