Reassemble a chunked Hedera Consensus Service message
A logical HCS message may be submitted in several transactions. Concatenating neighboring topic messages can mix unrelated submissions when another publisher writes between chunks.
Group the chunks before concatenation
Group by network, topic ID and the complete initialTransactionID carried in chunk metadata. Verify a consistent total and one copy of every number from one through total. Keep the binary payload of each chunk until the group is complete.
topic: 0.0.700
initialTransactionID: SAME_ID
arrivals: [ {number: 2, total: 3}, {number: 1, total: 3}, {number: 3, total: 3} ]
assembly order: 1, 2, 3
Handle retries and incomplete groups
For the three arrivals shown, reorder by number before decoding the final bytes as application data. A repeated chunk with identical bytes is safe to deduplicate; conflicting bytes or totals need investigation. If chunk 2 never appears, record an incomplete message and the observed consensus positions rather than decoding parts 1 and 3 as a complete document.