Wouldn't be easier for the nodes to just build the messages with JSON, then encode it to bytes so it can be transmitted over TCP/IP? I'm not talking about JSON-RPC, but the communication between nodes.


It would:

  • Use significantly more CPU to parse the incoming data (and running a node is already intensive, especially when processing an incoming block).
  • Use significantly more bandwidth.

It would not:

  • Remove the need for nodes to know about the binary format, as that is used for defining the (protocol-defined) hashes of transactions, blocks, and other structures.

So if you're going to need to implement the binary format anyway for hashing, why bother implementing another more expensive, less efficient layer on top, and incur the complexity of the conversion?

| improve this answer | |

When it comes to bandwidth and CPU usage (for serializing/deserializing), JSON is a terrible format. It literally passes a label with every single field, regardless of how often that field is repeated. It also passes numbers (both floating point and integer) as strings, which again, wastes bandwidth. This does not scale well at all.

JSON is designed to be used with flexible object schemas, where you don't know ahead of time which fields your data may or may not contain. That's why all the labelling is required. Since this isn't a problem that Bitcoin has, there is no real advantage to using a flexible data format.

It's a tradeoff between bandwidth/cpu versus flexibility, and Bitcoin data does not need the flexibility.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.