what happens if the receiver's index is stale and one of the files changes during the transfer? do you verify the final reconstructed stream end to end before giving it back to the command or is correctness relying on the block hashes?
Wow, I don't know what happened... your comment was posted 11 days ago but it only became visible for me now!
do you verify the final reconstructed stream end to end before giving it back to the command
No, I excluded that design from consideration, for two reasons: 1. It would make everything much slower given the use cases hashsync is intended to be used for. A command pipeline finishes much faster if the hashsync's output starts to be emitted as soon as it's received. 2. Even if performance wasn't an issue, it wouldn't work for rsync, since it requires back-and-forth communication between the rsync instances that run on each host. If hashsync kept the output to itself until it had received the entire data stream, rsync would hang. So correctness does rely on the block hashes, which would only be a problem if there was a hash collision, which is practically impossible given that hashsync uses 256-bit cryptographically-strong hashes (Blake3 or optionally, SHA-256). If the index is outdated or an external process races to modify a file while hashsync reads it, it doesn't cause a correctness issue: the block hash is always recomputed after the block is read into memory, before it's transmitted as a reference. If the hash doesn't match anymore, hashsync will discard that block and try to use another block with the same hash -- or if there is no other copy that was indexed, hashsync will transfer the block's (compressed) contents rather than a reference to the block. In reality, it may not even send the entire block's contents: e.g. if 10 bytes later hashsync again finds a block in the index with a matching hash, it may send those 10 bytes as a literal value, followed by a reference to the new block's hash.