Nit: Starting with C++17 you don’t need to specify redundant template parameters to constructor calls. Also some other style nits (feel free to ignore):
 0diff --git a/src/addrdb.cpp b/src/addrdb.cpp
 1index cee8d5e66a..900ba41025 100644
 2--- a/src/addrdb.cpp
 3+++ b/src/addrdb.cpp
 4@@ -34,7 +34,7 @@ bool SerializeDB(Stream& stream, const Data& data)
 5 {
 6     // Write and commit header, data
 7     try {
 8-        CHashedSourceWriter<Stream> hashwriter(&stream);
 9+        CHashedSourceWriter hashwriter{stream};
10         hashwriter << Params().MessageStart() << data;
11         hashwriter << hashwriter.GetHash();
12     } catch (const std::exception& e) {
13diff --git a/src/hash.h b/src/hash.h
14index 7b2f82c456..31370c301a 100644
15--- a/src/hash.h
16+++ b/src/hash.h
17@@ -6,6 +6,7 @@
18 #ifndef BITCOIN_HASH_H
19 #define BITCOIN_HASH_H
20 
21+#include <attributes.h>
22 #include <crypto/common.h>
23 #include <crypto/ripemd160.h>
24 #include <crypto/sha256.h>
25@@ -204,23 +205,22 @@ template <typename Source>
26 class CHashedSourceWriter : public CHashWriter
27 {
28 private:
29-    Source* source;
30+    Source& m_source;
31 
32 public:
33-    explicit CHashedSourceWriter(Source* source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {}
34+    explicit CHashedSourceWriter(Source& source LIFETIMEBOUND) : CHashWriter{source.GetType(), source.GetVersion()}, m_source{source} {}
35 
36     void write(Span<const std::byte> src)
37     {
38-        source->write(src);
39+        m_source.write(src);
40         CHashWriter::write(src);
41     }
42 
43     template <typename T>
44     CHashedSourceWriter<Source>& operator<<(const T& obj)
45     {
46-        // Serialize to this stream
47         ::Serialize(*this, obj);
48-        return (*this);
49+        return *this;
50     }
51 };
52 
53diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
54index 7d2a1b6818..90ad61ca6c 100644
55--- a/src/test/streams_tests.cpp
56+++ b/src/test/streams_tests.cpp
57@@ -503,11 +503,11 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
58 BOOST_AUTO_TEST_CASE(streams_hashed)
59 {
60     CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION);
61-    CHashedSourceWriter<CDataStream> hash_writer(&stream);
62+    CHashedSourceWriter hash_writer{stream};
63     const std::string data{"bitcoin"};
64     hash_writer << data;
65 
66-    CHashVerifier<CDataStream> hash_verifier(&stream);
67+    CHashVerifier hash_verifier{stream};
68     std::string result;
69     hash_verifier >> result;
70     BOOST_CHECK_EQUAL(data, result);