zmq: Add jsonblock, jsontx #14876

pull ch4ot1c wants to merge 3 commits into bitcoin:master from ch4ot1c:feature/zmq-json changing 5 files +64 −2
  1. ch4ot1c commented at 8:08 PM on December 5, 2018: contributor

    These changes allow ZMQ to publish its updates for txs and blocks as human-readable JSON, as opposed to in the raw Bitcoin format. Output data corresponds to verbosity level 1.

    Closes #14873

  2. promag commented at 9:48 PM on December 5, 2018: member

    Have you seen #11614?

  3. fanquake added the label RPC/REST/ZMQ on Dec 5, 2018
  4. ch4ot1c commented at 10:20 PM on December 5, 2018: contributor

    @promag Thanks for showing me that - I hadn't seen it.

    I think the prior discussion is great; I value these changes for the same reasons as @astanway:

    • Swift / Objective-C doesn't have a transaction or block parsing library available; I would like to avoid custom code involving varint, etc. This "portability" concern will almost certainly appear again.
    • I am using @fanquake's CoreRPC for an iOS project. ZMQ is a nice complement, and I can use it to determine the chaintip update event, but would much prefer it in a deserialized format. Assuming I don't want to "roll my own" parser:
    • No unnecessary roundtrip from an additional RPC call (getblock)

    Perhaps there is a bit of bias in the prior discussion, since experts @luke-jr and @dcousens dismissed it as "easy to implement". I think there is an important question raised:

    However, if ease of application development is not a priority for the project, then sure - happy to close.

    The tradeoffs seem to favor having an option for JSON, since we already serve JSON over RPC.

  5. laanwj commented at 2:27 PM on December 6, 2018: member

    I don't think JSON and ZMQ is a good combination. The formatting overhead for JSON kind of defeats the purpose of a low-latency networking system like ZMQ.

    I don't disagree it could be useful for some cases though.

  6. ch4ot1c force-pushed on Dec 7, 2018
  7. zmq: Add jsonblock, jsontx a1359a8b70
  8. fixup: Skip circular dependency 8bc46c845f
  9. ch4ot1c force-pushed on Dec 7, 2018
  10. ch4ot1c force-pushed on Dec 7, 2018
  11. fixup: Move include for rawtransaction 4ebf8a770f
  12. ch4ot1c force-pushed on Dec 7, 2018
  13. gmaxwell commented at 2:50 PM on December 9, 2018: contributor

    @laanwj That was also my thought on seeing the PR title.

  14. ch4ot1c commented at 4:38 PM on December 9, 2018: contributor

    I hear the response - fair enough. What could be done next / instead? Any room for it to be optional or are we marking it 'bad practice'?

  15. laanwj commented at 4:43 PM on December 9, 2018: member

    I hear the response - fair enough. What could be done next / instead?

    If performance isn't important, otherwise you'd be using a client-side decoding library, but you're using zmq as a notification mechanism, why is the extra roundtrip to call getblock or decoderawtransaction such a problem?

  16. ch4ot1c commented at 8:19 PM on December 9, 2018: contributor

    A small performance hit in-transit would cost less and be more reliable than two (1 zmq 1 rpc) networking events, I guess was my reasoning. The duplicate call would mean more transferred data in total than zmq with JSON formatting. I'm only interested in the latest block's stats.

    Implementing parsing on clients makes the most sense, agreed.

    hashblock is all I really needed. hashtx, rawtx, and decoderawtransaction got me mixed up in unneeded possibilities.

    This might sound useless or even confusing, but for symmetry, we could consider decoderawblock as an RPC. There is already submitblock whose interface seemingly makes more sense for bitcoind, as it checks its existence against the block db unavoidably, but doesn't return a JSON representation of the block.

  17. ch4ot1c commented at 8:29 PM on December 9, 2018: contributor

    A defensive check could also be added regarding the max expected size of rawblock and rawtx.

  18. jonasschnelli commented at 8:50 PM on December 9, 2018: contributor

    I agree with @laanwj about JSON probably not being something we should have in conjunction with ZMQ.

    I think a path for having JSON push notification would be the RPC long polling feature. A first step could be: #13262 (outdated)

  19. promag commented at 2:01 PM on December 10, 2018: member

    I agree with @jonasschnelli. @ch4ot1c don't forget that at the moment zmq notifications happen on the "main" thread. RPC is handled on a thread pool.

  20. laanwj commented at 6:08 PM on January 9, 2019: member

    As there is no agreement to do this I'm closing this PR

  21. laanwj closed this on Jan 9, 2019

  22. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me