You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My primaryKey variable follows this structure but without any blockHash field. Please note, there's ONLY ONE key which starts with this structure because the blockHeight is always different. So I was wondering, if I want this key in order to get the blockHash field, the code would be directly:
leveldb::Iterator* it { getNewIterator() };
std::string const primaryKey { std::string(bestBlockKey.constData(), bestBlockKey.length()) }; // Get the key PREFIX// Seek the key.// This will always start with the PREFIX so a it->key().starts_with(primaryKey) is not necessary ?// Should never fail otherwise, the key is not in the database.
it->Seek(primaryKey);
// Verify if the seek is valid and not invalid.// If the key doesn't exist, this will return false.if(it->Valid() && it->key().starts_with(primaryKey))
{
// Parse the key and the value.
}
delete it;
Is it correct ? Do a it->Seek(primaryKey) always will return the key which starts with the PREFIX if it is in the database ?
The text was updated successfully, but these errors were encountered:
Hi, I know there's this implementation of the iterator available in the documentation:
However, in my database the PREFIX follows this structure:
KEY_BLOCK (1 Byte) + blockHeight (8 Bytes) + blockHash (32 Bytes)
My
primaryKey
variable follows this structure but without any blockHash field. Please note, there's ONLY ONE key which starts with this structure because the blockHeight is always different. So I was wondering, if I want this key in order to get theblockHash
field, the code would be directly:Is it correct ? Do a
it->Seek(primaryKey)
always will return the key which starts with the PREFIX if it is in the database ?The text was updated successfully, but these errors were encountered: