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

Method ParseLastPos

src/persistence/dexdb.cpp:36–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36shared_ptr<string> DEX_DB::ParseLastPos(const string &lastPosInfo, DEXBlockOrdersCache::KeyType &lastKey) {
37
38 CDataStream ds(lastPosInfo, SER_DISK, CLIENT_VERSION);
39 uint256 lastBlockHash;
40 ds >> lastBlockHash >> lastKey;
41 uint32_t lastHeight = DEX_DB::GetHeight(lastKey);
42 CBlockIndex *pBlockIndex = chainActive[lastHeight];
43 if (pBlockIndex == nullptr)
44 return make_shared<string>(strprintf("The last_pos_info is not contained in active chains,"
45 " last_height=%d, tip_height=%d", lastHeight, chainActive.Height()));
46 if (pBlockIndex->GetBlockHash() != lastBlockHash)
47 return make_shared<string>(strprintf("The block of height in last_pos_info does not match with the active block,"
48 " height=%d, last_block_hash=%s, cur_height_block_hash=%s",
49 lastHeight, lastBlockHash.ToString(), pBlockIndex->GetBlockHash().ToString()));
50 return nullptr;
51}
52
53shared_ptr<string> DEX_DB::MakeLastPos(const DEXBlockOrdersCache::KeyType &lastKey, string &lastPosInfo) {
54 uint32_t lastHeight = DEX_DB::GetHeight(lastKey);

Callers

nothing calls this directly

Calls 4

HeightMethod · 0.80
GetHeightFunction · 0.70
GetBlockHashMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected