TensorCash kế thừa nguyên vẹn giao diện pub/sub ZMQ của Bitcoin Core. Publisher bind (mặc định tcp://127.0.0.1:28332); subscriber kết nối và đăng ký theo tiền tố topic. Mỗi thông báo là một thông điệp multipart ba frame, và cấu trúc body của từng topic được liệt kê bên dưới.
5 topic · nguồn gốc: inherit
Trang này trình bày cơ chế pub/sub kế thừa từ Bitcoin Core. Kênh kiểm chứng từ node tới verifier là một luồng ZMQ PUSH/PULL riêng, có payload dùng Schema FlatBuffer: proof.fbs, validation.fbs và blockheader.fbs.
Cấu trúc frame
Publisher binds; subscribers connect and SUBSCRIBE to topic prefixes. Topic strings are matched as byte prefixes — SUBSCRIBE "hash" receives both hashblock and hashtx.
Khung
Trường
Kiểu
Mô tả
0
topic
utf-8 string
One of the topic names below.
1
body
per-topic
Defined by the topic. See frames[1] per topic.
2
sequence_counter
uint32 little-endian
Monotonically increasing per-topic counter. Subscribers detect dropped messages by checking for gaps. Resets on bcore restart.
Topic
hashblock
-zmqpubhashblock=<address>
Best-block-tip changed (new block connected to the active chain).
A block is connected to the main chain. Fires once per UpdatedBlockTip callback.
Khung
Trường
Kiểu
Mô tả
1
block_hash
32 bytes, little-endian (display-reversed)
The connecting block's hash. Note Bitcoin Core's display convention reverses byte order — the wire bytes are little-endian; tooling that prints hex usually reverses them for display.
Transaction entered the mempool or was confirmed in a block.
Fires for every TransactionAddedToMempool and BlockConnected event; may emit duplicates for the same hash if a tx is re-broadcast or re-mined after a reorg.
Same trigger as hashblock — but the body is the full block, not just its hash. Heavier; only enable if a subscriber actually needs full block bytes (e.g. an indexer that does not have its own bcore peer).
Khung
Trường
Kiểu
Mô tả
1
block_serialized
variable-length bytes
The block, serialized using Bitcoin Core's standard block serialization (CBlock::Serialize). Includes the header, tx count (var_int), and all transactions in order.
Same trigger as hashtx — body is the full serialized transaction (CTransaction::Serialize). Subscribers can fully decode without round-tripping to JSON-RPC.
Khung
Trường
Kiểu
Mô tả
1
tx_serialized
variable-length bytes
The transaction, serialized with Bitcoin Core's standard transaction serialization. Witness data included when present.
Block-connect, block-disconnect, mempool-accept, and mempool-remove events. The body's event byte tells subscribers which type. Useful for indexers that need a single ordered event stream rather than the separate hashblock/hashtx topics.
Khung
Trường
Kiểu
Mô tả
1
hash + event_byte (+ optional mempool_seq)
32-byte hash || 1-byte event || optional 8-byte LE mempool_sequence
Body layout depends on the event: • 'C' (block connect) — hash || 'C' • 'D' (block disconnect) — hash || 'D' • 'A' (mempool accept) — hash || 'A' || mempool_sequence (uint64 LE) • 'R' (mempool remove) — hash || 'R' || mempool_sequence (uint64 LE) The 32-byte hash is little-endian on the wire (same convention as the hash topics). mempool_sequence is a separate per-mempool counter — distinct from the topic-level sequence_counter in frame 2.