mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
serialize boc with bfs (with multiget)
This commit is contained in:
parent
3c245c6146
commit
fbb9954391
14 changed files with 448 additions and 122 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "td/db/MemoryKeyValue.h"
|
||||
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/Span.h"
|
||||
|
||||
namespace td {
|
||||
Result<MemoryKeyValue::GetStatus> MemoryKeyValue::get(Slice key, std::string &value) {
|
||||
|
@ -30,6 +31,23 @@ Result<MemoryKeyValue::GetStatus> MemoryKeyValue::get(Slice key, std::string &va
|
|||
return GetStatus::Ok;
|
||||
}
|
||||
|
||||
Result<std::vector<MemoryKeyValue::GetStatus>> MemoryKeyValue::get_multi(td::Span<Slice> keys,
|
||||
std::vector<std::string> *values) {
|
||||
values->resize(keys.size());
|
||||
std::vector<GetStatus> res;
|
||||
for (size_t i = 0; i < keys.size(); i++) {
|
||||
auto it = map_.find(keys[i]);
|
||||
if (it == map_.end()) {
|
||||
res.push_back(GetStatus::NotFound);
|
||||
(*values)[i] = "";
|
||||
} else {
|
||||
res.push_back(GetStatus::Ok);
|
||||
(*values)[i] = it->second;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Status MemoryKeyValue::for_each(std::function<Status(Slice, Slice)> f) {
|
||||
for (auto &it : map_) {
|
||||
TRY_STATUS(f(it.first, it.second));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue