I agree that spans are better when all that is needed is to pass down data
and size
. I’ll leave this diff here up for grabs:
0diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp
1index 125bf004e4..46d12546c7 100644
2--- a/src/wallet/bdb.cpp
3+++ b/src/wallet/bdb.cpp
4@@ -804,7 +804,7 @@ std::string BerkeleyDatabaseVersion()
5 return DbEnv::version(nullptr, nullptr, nullptr);
6 }
7
8-bool BerkeleyBatch::ReadKey(CDataStream& key, CDataStream& value)
9+bool BerkeleyBatch::ReadKey(Span<char> key, CDataStream& value)
10 {
11 if (!pdb)
12 return false;
13@@ -822,7 +822,7 @@ bool BerkeleyBatch::ReadKey(CDataStream& key, CDataStream& value)
14 return false;
15 }
16
17-bool BerkeleyBatch::WriteKey(CDataStream& key, CDataStream& value, bool overwrite)
18+bool BerkeleyBatch::WriteKey(Span<char> key, Span<char> value, bool overwrite)
19 {
20 if (!pdb)
21 return true;
22@@ -840,7 +840,7 @@ bool BerkeleyBatch::WriteKey(CDataStream& key, CDataStream& value, bool overwrit
23 return (ret == 0);
24 }
25
26-bool BerkeleyBatch::EraseKey(CDataStream& key)
27+bool BerkeleyBatch::EraseKey(Span<char> key)
28 {
29 if (!pdb)
30 return false;
31@@ -855,7 +855,7 @@ bool BerkeleyBatch::EraseKey(CDataStream& key)
32 return (ret == 0 || ret == DB_NOTFOUND);
33 }
34
35-bool BerkeleyBatch::HasKey(CDataStream& key)
36+bool BerkeleyBatch::HasKey(Span<char> key)
37 {
38 if (!pdb)
39 return false;
40diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h
41index 1e717b95be..f5fa2da76a 100644
42--- a/src/wallet/bdb.h
43+++ b/src/wallet/bdb.h
44@@ -208,10 +208,10 @@ class BerkeleyBatch
45 };
46
47 private:
48- bool ReadKey(CDataStream& key, CDataStream& value);
49- bool WriteKey(CDataStream& key, CDataStream& value, bool overwrite=true);
50- bool EraseKey(CDataStream& key);
51- bool HasKey(CDataStream& key);
52+ bool ReadKey(Span<char> key, CDataStream& value);
53+ bool WriteKey(Span<char> key, Span<char> value, bool overwrite = true);
54+ bool EraseKey(Span<char> key);
55+ bool HasKey(Span<char> key);
56
57 protected:
58 Db* pdb;