/*
This file is part of TON Blockchain Library.
TON Blockchain Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
TON Blockchain Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see .
Copyright 2017-2020 Telegram Systems LLP
*/
#pragma once
#include "td/actor/actor.h"
#include "tonlib/Config.h"
#include "tonlib/ExtClient.h"
#include "td/utils/CancellationToken.h"
#include "td/utils/tl_helpers.h"
#include "block/mc-config.h"
namespace tonlib {
struct LastConfigState {
std::shared_ptr config;
td::Ref prev_blocks_info;
};
td::StringBuilder& operator<<(td::StringBuilder& sb, const LastConfigState& state);
class LastConfig : public td::actor::Actor {
public:
class Callback {
public:
virtual ~Callback() {
}
};
explicit LastConfig(ExtClientRef client, td::unique_ptr callback);
void get_last_config(td::Promise promise);
private:
td::unique_ptr callback_;
ExtClient client_;
LastConfigState state_;
enum class QueryState { Empty, Active, Done };
QueryState get_config_state_{QueryState::Empty};
std::vector> promises_;
std::vector params_{4, 18, 20, 21, 24, 25};
void with_last_block(td::Result r_last_block);
void on_config(td::Result> r_config);
td::Status process_config(td::Result> r_config);
td::Status process_config_proof(ton::ton_api::object_ptr config);
void on_ok();
void on_error(td::Status status);
void loop() override;
void tear_down() override;
};
} // namespace tonlib