本文整理汇总了C++中BinaryDataRef::startsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryDataRef::startsWith方法的具体用法?C++ BinaryDataRef::startsWith怎么用?C++ BinaryDataRef::startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryDataRef
的用法示例。
在下文中一共展示了BinaryDataRef::startsWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateZCinDB
void ZeroConfContainer::updateZCinDB(const vector<BinaryData>& keysToWrite,
const vector<BinaryData>& keysToDelete)
{
//should run in its own thread to make sure we can get a write tx
DB_SELECT dbs = BLKDATA;
if (db_->getDbType() != ARMORY_DB_SUPER)
dbs = HISTORY;
LMDBEnv::Transaction tx;
db_->beginDBTransaction(&tx, dbs, LMDB::ReadWrite);
for (auto& key : keysToWrite)
{
StoredTx zcTx;
zcTx.createFromTx(txMap_[key], true, true);
db_->putStoredZC(zcTx, key);
}
for (auto& key : keysToDelete)
{
BinaryData keyWithPrefix;
if (key.getSize() == 6)
{
keyWithPrefix.resize(7);
uint8_t* keyptr = keyWithPrefix.getPtr();
keyptr[0] = DB_PREFIX_ZCDATA;
memcpy(keyptr + 1, key.getPtr(), 6);
}
else
keyWithPrefix = key;
LDBIter dbIter(db_->getIterator(dbs));
if (!dbIter.seekTo(keyWithPrefix))
continue;
vector<BinaryData> ktd;
do
{
BinaryDataRef thisKey = dbIter.getKeyRef();
if (!thisKey.startsWith(keyWithPrefix))
break;
ktd.push_back(thisKey);
}
while (dbIter.advanceAndRead(DB_PREFIX_ZCDATA));
for (auto Key : ktd)
db_->deleteValue(dbs, Key);
}
}