MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / DbCacheToString

Function DbCacheToString

src/rpc/rpcmisc.cpp:357–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355
356
357string DbCacheToString(CBlockIndexDB &cache) {
358 std::shared_ptr<leveldb::Iterator> pCursor(cache.NewIterator());
359 const std::string &prefix = dbk::GetKeyPrefix(dbk::BLOCK_INDEX);
360 string str;
361 for (pCursor->Seek(prefix); pCursor->Valid(); pCursor->Next()) {
362 boost::this_thread::interruption_point();
363 try {
364 leveldb::Slice slKey = pCursor->key();
365 if (slKey.starts_with(prefix)) {
366 leveldb::Slice slValue = pCursor->value();
367 CDataStream ssValue(slValue.data(), slValue.data() + slValue.size(), SER_DISK, CLIENT_VERSION);
368 CDiskBlockIndex diskIndex;
369 ssValue >> diskIndex;
370 uint256 hash;
371 ParseDbKey(slKey, dbk::BLOCK_INDEX, hash);
372 str += strprintf("{%s}={%s},\n", hash.ToString(), diskIndex.ToString());
373
374 } else {
375 break; // if shutdown requested or finished loading block index
376 }
377 } catch (const std::exception &e) {
378 throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Deserialize or I/O error - %s", e.what()));
379 }
380 }
381
382 return strprintf("-->%s, data={%s}\n", prefix, str);
383}
384
385template<int32_t PREFIX_TYPE, typename KeyType, typename ValueType>
386string DbCacheToString(CCompositeKVCache<PREFIX_TYPE, KeyType, ValueType> &cache) {

Callers 2

DumpDbOneFunction · 0.85
DumpDbAllFunction · 0.85

Calls 15

ParseDbKeyFunction · 0.85
JSONRPCErrorFunction · 0.85
starts_withMethod · 0.80
dataMethod · 0.80
GetDataPtrMethod · 0.80
ToStringFunction · 0.50
NewIteratorMethod · 0.45
SeekMethod · 0.45
ValidMethod · 0.45
NextMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected