Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251return SendZmqMessage(MSG_RAWTX, &(*ss.begin()), ss.size());252}254// Helper function to send a 'sequence' topic message with the following structure:255// <32-byte hash> | <1-byte label> | <8-byte LE sequence> (optional)256static bool SendSequenceMsg(CZMQAbstractPublishNotifier& notifier, uint256 hash, char label, std::optional<uint64_t> sequence = {})257{258unsigned char data[sizeof(hash) + sizeof(label) + sizeof(uint64_t)];259for (unsigned int i = 0; i < sizeof(hash); ++i) {260data[sizeof(hash) - 1 - i] = hash.begin()[i];261}262data[sizeof(hash)] = label;263if (sequence) WriteLE64(data + sizeof(hash) + sizeof(label), *sequence);264return notifier.SendZmqMessage(MSG_SEQUENCE, data, sequence ? sizeof(data) : sizeof(hash) + sizeof(label));265}267bool CZMQPublishSequenceNotifier::NotifyBlockConnect(const CBlockIndex *pindex)268{269uint256 hash = pindex->GetBlockHash();270LogDebug(BCLog::ZMQ, "Publish sequence block connect %s to %s\n", hash.GetHex(), this->address);271return SendSequenceMsg(*this, hash, /* Block (C)onnect */ 'C');272}274bool CZMQPublishSequenceNotifier::NotifyBlockDisconnect(const CBlockIndex *pindex)275{276uint256 hash = pindex->GetBlockHash();277LogDebug(BCLog::ZMQ, "Publish sequence block disconnect %s to %s\n", hash.GetHex(), this->address);278return SendSequenceMsg(*this, hash, /* Block (D)isconnect */ 'D');279}281bool CZMQPublishSequenceNotifier::NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence)282{283uint256 hash = transaction.GetHash().ToUint256();284LogDebug(BCLog::ZMQ, "Publish hashtx mempool acceptance %s to %s\n", hash.GetHex(), this->address);285return SendSequenceMsg(*this, hash, /* Mempool (A)cceptance */ 'A', mempool_sequence);286}288bool CZMQPublishSequenceNotifier::NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence)289{290uint256 hash = transaction.GetHash().ToUint256();291LogDebug(BCLog::ZMQ, "Publish hashtx mempool removal %s to %s\n", hash.GetHex(), this->address);292return SendSequenceMsg(*this, hash, /* Mempool (R)emoval */ 'R', mempool_sequence);293}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.