Refactor similar compression buffer code in dircache.c
After #21377 (moved), we will have 3 copies of similar compression buffer code in dircache.c.
Copying code is a bad idea, because:
- people make mistakes when they copy, and
- when people make changes, they sometimes miss the copies.
Instead, we should write a function that correctly adds compressed or uncompressed data to the connection, based on conn, compress_method, uncompressed_body_len, lifetime, estimated_len, and the data that needs to be added to the buffer.
Perhaps the dirserv_spool_* functions could help here.
Then we can call the new function from handle_get_next_bandwidth(): https://github.com/torproject/tor/blob/b03091842bc4590e11e3ac026daae8ed6d8f7554/src/feature/dircache/dircache.c#L1463-L1468