aboutsummaryrefslogtreecommitdiff
path: root/src/zmq
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2015-09-16 16:42:23 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-09-16 16:51:21 +0200
commitd76a8acb9b7bcabf43e3e05168a36911f187818d (patch)
tree2322acc9cd1448c524e7507a517deca6da7cf43c /src/zmq
parent0143a1f228c3447ae2e025c697b0ad53a0d8d306 (diff)
downloadbitcoin-d76a8acb9b7bcabf43e3e05168a36911f187818d.tar.xz
use CBlockIndex* insted of uint256 for UpdatedBlockTip signal
- removes mapBlockIndex find operation - theoretically allows removing the cs_main lock during zqm notification while introducing a new file position lock
Diffstat (limited to 'src/zmq')
-rw-r--r--src/zmq/zmqabstractnotifier.cpp2
-rw-r--r--src/zmq/zmqabstractnotifier.h4
-rw-r--r--src/zmq/zmqnotificationinterface.cpp4
-rw-r--r--src/zmq/zmqnotificationinterface.h3
-rw-r--r--src/zmq/zmqpublishnotifier.cpp12
-rw-r--r--src/zmq/zmqpublishnotifier.h6
6 files changed, 17 insertions, 14 deletions
diff --git a/src/zmq/zmqabstractnotifier.cpp b/src/zmq/zmqabstractnotifier.cpp
index 744ec59234..9f5cb3ba67 100644
--- a/src/zmq/zmqabstractnotifier.cpp
+++ b/src/zmq/zmqabstractnotifier.cpp
@@ -11,7 +11,7 @@ CZMQAbstractNotifier::~CZMQAbstractNotifier()
assert(!psocket);
}
-bool CZMQAbstractNotifier::NotifyBlock(const uint256 &/*hash*/)
+bool CZMQAbstractNotifier::NotifyBlock(const CBlockIndex * /*CBlockIndex*/)
{
return true;
}
diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h
index 626d1ddf92..77cf5141e2 100644
--- a/src/zmq/zmqabstractnotifier.h
+++ b/src/zmq/zmqabstractnotifier.h
@@ -7,7 +7,9 @@
#include "zmqconfig.h"
+class CBlockIndex;
class CZMQAbstractNotifier;
+
typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)();
class CZMQAbstractNotifier
@@ -30,7 +32,7 @@ public:
virtual bool Initialize(void *pcontext) = 0;
virtual void Shutdown() = 0;
- virtual bool NotifyBlock(const uint256 &hash);
+ virtual bool NotifyBlock(const CBlockIndex *pindex);
virtual bool NotifyTransaction(const CTransaction &transaction);
protected:
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
index 71ccb59a4a..388b86707b 100644
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -120,12 +120,12 @@ void CZMQNotificationInterface::Shutdown()
}
}
-void CZMQNotificationInterface::UpdatedBlockTip(const uint256 &hash)
+void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
{
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
- if (notifier->NotifyBlock(hash))
+ if (notifier->NotifyBlock(pindex))
{
i++;
}
diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h
index afc0b8d24e..8eea15c068 100644
--- a/src/zmq/zmqnotificationinterface.h
+++ b/src/zmq/zmqnotificationinterface.h
@@ -9,6 +9,7 @@
#include <string>
#include <map>
+class CBlockIndex;
class CZMQAbstractNotifier;
class CZMQNotificationInterface : public CValidationInterface
@@ -23,7 +24,7 @@ public:
protected: // CValidationInterface
void SyncTransaction(const CTransaction &tx, const CBlock *pblock);
- void UpdatedBlockTip(const uint256 &newHashTip);
+ void UpdatedBlockTip(const CBlockIndex *pindex);
private:
CZMQNotificationInterface();
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index 0a6d7d0dbc..4c3eb8f2d9 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -116,8 +116,9 @@ void CZMQAbstractPublishNotifier::Shutdown()
psocket = 0;
}
-bool CZMQPublishHashBlockNotifier::NotifyBlock(const uint256 &hash)
+bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
+ uint256 hash = pindex->GetBlockHash();
LogPrint("zmq", "Publish hash block %s\n", hash.GetHex());
char data[32];
for (unsigned int i = 0; i < 32; i++)
@@ -137,18 +138,15 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t
return rc == 0;
}
-bool CZMQPublishRawBlockNotifier::NotifyBlock(const uint256 &hash)
+bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
- LogPrint("zmq", "Publish raw block %s\n", hash.GetHex());
+ LogPrint("zmq", "Publish raw block %s\n", pindex->GetBlockHash().GetHex());
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
{
LOCK(cs_main);
-
CBlock block;
- CBlockIndex* pblockindex = mapBlockIndex[hash];
-
- if(!ReadBlockFromDisk(block, pblockindex))
+ if(!ReadBlockFromDisk(block, pindex))
{
zmqError("Can't read block from disk");
return false;
diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h
index a0eb26f5e2..44d5cbea67 100644
--- a/src/zmq/zmqpublishnotifier.h
+++ b/src/zmq/zmqpublishnotifier.h
@@ -7,6 +7,8 @@
#include "zmqabstractnotifier.h"
+class CBlockIndex;
+
class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
{
public:
@@ -17,7 +19,7 @@ public:
class CZMQPublishHashBlockNotifier : public CZMQAbstractPublishNotifier
{
public:
- bool NotifyBlock(const uint256 &hash);
+ bool NotifyBlock(const CBlockIndex *pindex);
};
class CZMQPublishHashTransactionNotifier : public CZMQAbstractPublishNotifier
@@ -29,7 +31,7 @@ public:
class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier
{
public:
- bool NotifyBlock(const uint256 &hash);
+ bool NotifyBlock(const CBlockIndex *pindex);
};
class CZMQPublishRawTransactionNotifier : public CZMQAbstractPublishNotifier