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

updated tonlib, block routing

- upated tonlib
- fixed bug in message routing
This commit is contained in:
ton 2019-09-28 11:44:38 +04:00
parent ac3eb1a7b8
commit fd7a8de970
33 changed files with 1002 additions and 381 deletions

View file

@ -77,6 +77,7 @@ struct IntCtx {
vm::TonDb* ton_db{nullptr};
Dictionary* dictionary{nullptr};
SourceLookup* source_lookup{nullptr};
int* now{nullptr};
private:
std::string str;

View file

@ -20,6 +20,7 @@
#include <iostream>
#include "td/utils/Status.h"
#include "td/utils/Time.h"
namespace fift {
class FileLoader {
@ -43,10 +44,21 @@ class OsFileLoader : public FileLoader {
bool is_file_exists(td::CSlice filename) override;
};
class OsTime {
public:
virtual ~OsTime() = default;
virtual td::uint32 now() = 0;
};
//TODO: rename SourceLookup
class SourceLookup {
public:
SourceLookup() = default;
explicit SourceLookup(std::unique_ptr<FileLoader> file_loader) : file_loader_(std::move(file_loader)) {
explicit SourceLookup(std::unique_ptr<FileLoader> file_loader, std::unique_ptr<OsTime> os_time = {})
: file_loader_(std::move(file_loader)), os_time_(std::move(os_time)) {
}
void set_os_time(std::unique_ptr<OsTime> os_time) {
os_time_ = std::move(os_time);
}
void add_include_path(td::string path);
td::Result<FileLoader::File> lookup_source(std::string filename, std::string current_dir);
@ -63,9 +75,16 @@ class SourceLookup {
bool is_file_exists(td::CSlice filename) {
return file_loader_->is_file_exists(filename);
}
td::uint32 now() {
if (os_time_) {
return os_time_->now();
}
return static_cast<td::uint32>(td::Time::now());
}
protected:
std::unique_ptr<FileLoader> file_loader_;
std::unique_ptr<OsTime> os_time_;
std::vector<std::string> source_include_path_;
};
} // namespace fift

View file

@ -1289,8 +1289,8 @@ void interpret_file_exists(IntCtx& ctx) {
// custom and crypto
void interpret_now(vm::Stack& stack) {
stack.push_smallint(std::time(nullptr));
void interpret_now(IntCtx& ctx) {
ctx.stack.push_smallint(ctx.source_lookup->now());
}
void interpret_new_keypair(vm::Stack& stack) {
@ -2534,7 +2534,7 @@ void init_words_common(Dictionary& d) {
d.def_ctx_word("B>file ", interpret_write_file);
d.def_ctx_word("file-exists? ", interpret_file_exists);
// custom & crypto
d.def_stack_word("now ", interpret_now);
d.def_ctx_word("now ", interpret_now);
d.def_stack_word("newkeypair ", interpret_new_keypair);
d.def_stack_word("priv>pub ", interpret_priv_key_to_pub);
d.def_stack_word("ed25519_sign ", interpret_ed25519_sign);