Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqpublishnotifier.cpp
// Copyright (c) 2015-2016 The Bitcoin Core developers | // Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <zmq/zmqpublishnotifier.h> | #include <zmq/zmqpublishnotifier.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | |||||
#include <config.h> | #include <config.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <util.h> | #include <util.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <cstdarg> | #include <cstdarg> | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { | ||||
LogPrint(BCLog::ZMQ, "zmq: Publish rawblock %s\n", | LogPrint(BCLog::ZMQ, "zmq: Publish rawblock %s\n", | ||||
pindex->GetBlockHash().GetHex()); | pindex->GetBlockHash().GetHex()); | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); | CDataStream ss(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CBlock block; | CBlock block; | ||||
if (!ReadBlockFromDisk(block, pindex, config)) { | if (!ReadBlockFromDisk(block, pindex, | ||||
config.GetChainParams().GetConsensus())) { | |||||
zmqError("Can't read block from disk"); | zmqError("Can't read block from disk"); | ||||
return false; | return false; | ||||
} | } | ||||
ss << block; | ss << block; | ||||
} | } | ||||
return SendMessage(MSG_RAWBLOCK, &(*ss.begin()), ss.size()); | return SendMessage(MSG_RAWBLOCK, &(*ss.begin()), ss.size()); | ||||
Show All 10 Lines |