Why does the txn_count field exists in a block? I was wondering why the txn_count field in a block exists. The count of transactions could be determined by parsing the txns field in tx format, right? Same for 'tx_in count' and 'tx_out count' in a transaction. The tx_in and tx_out can be just parsed and the count can be determined based on that, right? Is this true? And if it's true, why do the txn_count, tx_in count and tx_out count fields exist?
Serialization is certainly not my area of expertise, but I'd guess: one challenge with serialized data is to know how much data to read. Explicitly providing the count of objects (and their length) you're about to parse is likely simpler and safer than having multiple levels of terminators in a hierarchical data structure and may actually require less data overall.