Move SafeDbt out of BerkeleyBatch
This commit is contained in:
1 parent
6061eb6564
commit
69efbc011b
2 files changed
+9
-9
No files matched your search
+6
-6
@@ -220,17 +220,17 @@ BerkeleyEnvironment::BerkeleyEnvironment() : m_use_shared_memory(false)
|
|||||||
fMockDb = true;
|
fMockDb = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BerkeleyBatch::SafeDbt::SafeDbt()
|
SafeDbt::SafeDbt()
|
||||||
{
|
{
|
||||||
m_dbt.set_flags(DB_DBT_MALLOC);
|
m_dbt.set_flags(DB_DBT_MALLOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
BerkeleyBatch::SafeDbt::SafeDbt(void* data, size_t size)
|
SafeDbt::SafeDbt(void* data, size_t size)
|
||||||
: m_dbt(data, size)
|
: m_dbt(data, size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BerkeleyBatch::SafeDbt::~SafeDbt()
|
SafeDbt::~SafeDbt()
|
||||||
{
|
{
|
||||||
if (m_dbt.get_data() != nullptr) {
|
if (m_dbt.get_data() != nullptr) {
|
||||||
// Clear memory, e.g. in case it was a private key
|
// Clear memory, e.g. in case it was a private key
|
||||||
@@ -244,17 +244,17 @@ BerkeleyBatch::SafeDbt::~SafeDbt()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* BerkeleyBatch::SafeDbt::get_data() const
|
const void* SafeDbt::get_data() const
|
||||||
{
|
{
|
||||||
return m_dbt.get_data();
|
return m_dbt.get_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BerkeleyBatch::SafeDbt::get_size() const
|
uint32_t SafeDbt::get_size() const
|
||||||
{
|
{
|
||||||
return m_dbt.get_size();
|
return m_dbt.get_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
BerkeleyBatch::SafeDbt::operator Dbt*()
|
SafeDbt::operator Dbt*()
|
||||||
{
|
{
|
||||||
return &m_dbt;
|
return &m_dbt;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -165,9 +165,6 @@ public:
|
|||||||
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override;
|
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** RAII class that provides access to a Berkeley database */
|
|
||||||
class BerkeleyBatch : public DatabaseBatch
|
|
||||||
{
|
|
||||||
/** RAII class that automatically cleanses its data on destruction */
|
/** RAII class that automatically cleanses its data on destruction */
|
||||||
class SafeDbt final
|
class SafeDbt final
|
||||||
{
|
{
|
||||||
@@ -188,6 +185,9 @@ class BerkeleyBatch : public DatabaseBatch
|
|||||||
operator Dbt*();
|
operator Dbt*();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** RAII class that provides access to a Berkeley database */
|
||||||
|
class BerkeleyBatch : public DatabaseBatch
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
bool ReadKey(CDataStream&& key, CDataStream& value) override;
|
bool ReadKey(CDataStream&& key, CDataStream& value) override;
|
||||||
bool WriteKey(CDataStream&& key, CDataStream&& value, bool overwrite = true) override;
|
bool WriteKey(CDataStream&& key, CDataStream&& value, bool overwrite = true) override;
|
||||||
|
|||||||
Reference in new issue
Block a user