walletdb: Consistently clear key and value streams before writing
Before writing data to the output key and value streams, make sure they are cleared.
This commit is contained in:
1 parent
71300489af
commit
84b2f353bb
3 files changed
+8
No files matched your search
@@ -100,6 +100,8 @@ DatabaseCursor::Status MockableCursor::Next(DataStream& key, DataStream& value)
|
||||
if (m_cursor == m_cursor_end) {
|
||||
return Status::DONE;
|
||||
}
|
||||
key.clear();
|
||||
value.clear();
|
||||
const auto& [key_data, value_data] = *m_cursor;
|
||||
key.write(key_data);
|
||||
value.write(value_data);
|
||||
@@ -117,6 +119,7 @@ bool MockableBatch::ReadKey(DataStream&& key, DataStream& value)
|
||||
if (it == m_records.end()) {
|
||||
return false;
|
||||
}
|
||||
value.clear();
|
||||
value.write(it->second);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user