MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ReadKey

Method ReadKey

src/wallet/sqlite.cpp:464–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464bool SQLiteBatch::ReadKey(DataStream&& key, DataStream& value)
465{
466 if (!m_database.m_db) return false;
467 assert(m_read_stmt);
468
469 // Bind: leftmost parameter in statement is index 1
470 if (!BindBlobToStatement(m_read_stmt, 1, key, "key")) return false;
471 int res = sqlite3_step(m_read_stmt);
472 if (res != SQLITE_ROW) {
473 if (res != SQLITE_DONE) {
474 // SQLITE_DONE means "not found", don't log an error in that case.
475 LogWarning("Unable to execute read statement: %s", sqlite3_errstr(res));
476 }
477 sqlite3_clear_bindings(m_read_stmt);
478 sqlite3_reset(m_read_stmt);
479 return false;
480 }
481 // Leftmost column in result is index 0
482 value.clear();
483 value.write(SpanFromBlob(m_read_stmt, 0));
484
485 sqlite3_clear_bindings(m_read_stmt);
486 sqlite3_reset(m_read_stmt);
487 return true;
488}
489
490bool SQLiteBatch::WriteKey(DataStream&& key, DataStream&& value, bool overwrite)
491{

Callers

nothing calls this directly

Calls 4

BindBlobToStatementFunction · 0.85
SpanFromBlobFunction · 0.85
clearMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected