This fixes a potential corruption of the peers.dat file that could prevent ai
node from restarting and force the user to manually delete the file.
> hash: add HashedSourceWriter
>
> This class is the counterpart to CHashVerifier, in that it
> writes data to an underlying source stream,
> while keeping a hash of the written data.
> addrdb: Only call Serialize() once
>
> The previous logic would call it once for serializing into the filestream,
> and then again for serializing into the hasher. If AddrMan was changed
> in between these calls by another thread, the resulting peers.dat would
> be corrupt with non-matching checksum and data.
> Fix this by using HashedSourceWriter, which writes the data
> to the underlying stream and keeps track of the hash in one go.
This is a backport of core#26909