1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

pow-testgiver support

This commit is contained in:
ton 2020-07-06 17:07:20 +03:00
parent dbde9c1c40
commit f064b1047a
257 changed files with 6665 additions and 2608 deletions

View file

@ -20,13 +20,12 @@
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/SharedSlice.h"
#include "td/utils/Slice.h"
#include "td/utils/StorerBase.h"
#include "td/utils/UInt.h"
//FIXME
#include "td/utils/SharedSlice.h"
#include "crypto/common/bitstring.h"
#include <cstring>
@ -38,7 +37,6 @@ class TlStorerUnsafe {
public:
explicit TlStorerUnsafe(unsigned char *buf) : buf_(buf) {
LOG_CHECK(is_aligned_pointer<4>(buf_)) << buf_;
}
TlStorerUnsafe(const TlStorerUnsafe &other) = delete;
@ -78,7 +76,7 @@ class TlStorerUnsafe {
*buf_++ = static_cast<unsigned char>(len & 255);
*buf_++ = static_cast<unsigned char>((len >> 8) & 255);
*buf_++ = static_cast<unsigned char>(len >> 16);
} else if (len < (1ull << 32)) {
} else if (static_cast<uint64>(len) < (static_cast<uint64>(1) << 32)) {
*buf_++ = static_cast<unsigned char>(255);
*buf_++ = static_cast<unsigned char>(len & 255);
*buf_++ = static_cast<unsigned char>((len >> 8) & 255);
@ -99,7 +97,7 @@ class TlStorerUnsafe {
// fallthrough
case 2:
*buf_++ = 0;
// fallthrough
// fallthrough
case 3:
*buf_++ = 0;
}
@ -160,12 +158,10 @@ class TlStorerCalcLength {
class TlStorerToString {
std::string result;
int shift = 0;
size_t shift = 0;
void store_field_begin(const char *name) {
for (int i = 0; i < shift; i++) {
result += ' ';
}
result.append(shift, ' ');
if (name && name[0]) {
result += name;
result += " = ";
@ -173,7 +169,7 @@ class TlStorerToString {
}
void store_field_end() {
result += "\n";
result += '\n';
}
void store_long(int64 value) {
@ -183,14 +179,14 @@ class TlStorerToString {
void store_binary(Slice data) {
static const char *hex = "0123456789ABCDEF";
result.append("{ ");
result.append("{ ", 2);
for (auto c : data) {
unsigned char byte = c;
result += hex[byte >> 4];
result += hex[byte & 15];
result += ' ';
}
result.append("}");
result += '}';
}
public:
@ -229,7 +225,7 @@ class TlStorerToString {
void store_field(const char *name, const string &value) {
store_field_begin(name);
result += '"';
result.append(value.data(), value.size());
result += value;
result += '"';
store_field_end();
}
@ -308,16 +304,14 @@ class TlStorerToString {
}
void store_class_end() {
CHECK(shift >= 2);
shift -= 2;
for (int i = 0; i < shift; i++) {
result += ' ';
}
result.append(shift, ' ');
result += "}\n";
CHECK(shift >= 0);
}
std::string str() const {
return result;
std::string move_as_str() {
return std::move(result);
}
};