Changeset View
Changeset View
Standalone View
Standalone View
src/zmq/zmqpublishnotifier.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | while (1) { | ||||
if (rc == -1) { | if (rc == -1) { | ||||
zmqError("Unable to send ZMQ msg"); | zmqError("Unable to send ZMQ msg"); | ||||
zmq_msg_close(&msg); | zmq_msg_close(&msg); | ||||
return -1; | return -1; | ||||
} | } | ||||
zmq_msg_close(&msg); | zmq_msg_close(&msg); | ||||
if (!data) break; | if (!data) { | ||||
break; | |||||
} | |||||
size = va_arg(args, size_t); | size = va_arg(args, size_t); | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
bool CZMQAbstractPublishNotifier::Initialize(void *pcontext) { | bool CZMQAbstractPublishNotifier::Initialize(void *pcontext) { | ||||
assert(!psocket); | assert(!psocket); | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | bool CZMQAbstractPublishNotifier::SendMessage(const char *command, | ||||
const void *data, size_t size) { | const void *data, size_t size) { | ||||
assert(psocket); | assert(psocket); | ||||
/* send three parts, command & data & a LE 4byte sequence number */ | /* send three parts, command & data & a LE 4byte sequence number */ | ||||
uint8_t msgseq[sizeof(uint32_t)]; | uint8_t msgseq[sizeof(uint32_t)]; | ||||
WriteLE32(&msgseq[0], nSequence); | WriteLE32(&msgseq[0], nSequence); | ||||
int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, | int rc = zmq_send_multipart(psocket, command, strlen(command), data, size, | ||||
msgseq, (size_t)sizeof(uint32_t), (void *)0); | msgseq, (size_t)sizeof(uint32_t), (void *)0); | ||||
if (rc == -1) return false; | if (rc == -1) { | ||||
return false; | |||||
} | |||||
/* increment memory only sequence number after sending */ | /* increment memory only sequence number after sending */ | ||||
nSequence++; | nSequence++; | ||||
return true; | return true; | ||||
} | } | ||||
bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { | bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { | ||||
uint256 hash = pindex->GetBlockHash(); | uint256 hash = pindex->GetBlockHash(); | ||||
LogPrint(BCLog::ZMQ, "zmq: Publish hashblock %s\n", hash.GetHex()); | LogPrint(BCLog::ZMQ, "zmq: Publish hashblock %s\n", hash.GetHex()); | ||||
char data[32]; | char data[32]; | ||||
for (unsigned int i = 0; i < 32; i++) | for (unsigned int i = 0; i < 32; i++) { | ||||
data[31 - i] = hash.begin()[i]; | data[31 - i] = hash.begin()[i]; | ||||
} | |||||
return SendMessage(MSG_HASHBLOCK, data, 32); | return SendMessage(MSG_HASHBLOCK, data, 32); | ||||
} | } | ||||
bool CZMQPublishHashTransactionNotifier::NotifyTransaction( | bool CZMQPublishHashTransactionNotifier::NotifyTransaction( | ||||
const CTransaction &transaction) { | const CTransaction &transaction) { | ||||
uint256 txid = transaction.GetId(); | uint256 txid = transaction.GetId(); | ||||
LogPrint(BCLog::ZMQ, "zmq: Publish hashtx %s\n", txid.GetHex()); | LogPrint(BCLog::ZMQ, "zmq: Publish hashtx %s\n", txid.GetHex()); | ||||
char data[32]; | char data[32]; | ||||
for (unsigned int i = 0; i < 32; i++) | for (unsigned int i = 0; i < 32; i++) { | ||||
data[31 - i] = txid.begin()[i]; | data[31 - i] = txid.begin()[i]; | ||||
} | |||||
return SendMessage(MSG_HASHTX, data, 32); | return SendMessage(MSG_HASHTX, data, 32); | ||||
} | } | ||||
bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) { | 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(); | ||||
Show All 23 Lines |