| 34 | } |
| 35 | |
| 36 | shared_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 | |
| 53 | shared_ptr<string> DEX_DB::MakeLastPos(const DEXBlockOrdersCache::KeyType &lastKey, string &lastPosInfo) { |
| 54 | uint32_t lastHeight = DEX_DB::GetHeight(lastKey); |
nothing calls this directly
no test coverage detected