/*
    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 "interfaces/validator-manager.h"
#include "interfaces/db.h"
#include "validator.h"
namespace ton {
namespace validator {
enum CollateMode { skip_store_candidate = 1 };
td::actor::ActorOwn create_db_actor(td::actor::ActorId manager, std::string db_root_,
                                        td::Ref opts);
td::actor::ActorOwn create_liteserver_cache_actor(td::actor::ActorId manager,
                                                                   std::string db_root);
td::Result> create_block(BlockIdExt block_id, td::BufferSlice data);
td::Result> create_block(ReceivedBlock data);
td::Result> create_proof(BlockIdExt masterchain_block_id, td::BufferSlice proof);
td::Result> create_proof_link(BlockIdExt block_id, td::BufferSlice proof);
td::Result> create_signature_set(td::BufferSlice sig_set);
td::Result> create_shard_state(BlockIdExt block_id, td::BufferSlice data);
td::Result> create_shard_state(BlockIdExt block_id, td::Ref root_cell);
td::Result create_block_handle(td::BufferSlice data);
td::Result create_block_handle(td::Slice data);
td::Result create_temp_block_handle(td::BufferSlice data);
BlockHandle create_empty_block_handle(BlockIdExt id);
td::Result> create_ext_message(td::BufferSlice data,
                                                   block::SizeLimitsConfig::ExtMsgLimits limits);
td::Result> create_ihr_message(td::BufferSlice data);
td::Result>> create_new_shard_block_descriptions(td::BufferSlice data);
td::Ref create_signature_set(std::vector sig_set);
void run_check_external_message(td::Ref message, td::actor::ActorId manager,
                                td::Promise> promise);
void run_accept_block_query(BlockIdExt id, td::Ref data, std::vector prev,
                            td::Ref validator_set, td::Ref signatures,
                            td::Ref approve_signatures, int send_broadcast_mode,
                            td::actor::ActorId manager, td::Promise promise);
void run_fake_accept_block_query(BlockIdExt id, td::Ref data, std::vector prev,
                                 td::Ref validator_set, td::actor::ActorId manager,
                                 td::Promise promise);
void run_hardfork_accept_block_query(BlockIdExt id, td::Ref data,
                                     td::actor::ActorId manager, td::Promise promise);
void run_apply_block_query(BlockIdExt id, td::Ref block, BlockIdExt masterchain_block_id,
                           td::actor::ActorId manager, td::Timestamp timeout,
                           td::Promise promise);
void run_check_proof_query(BlockIdExt id, td::Ref proof, td::actor::ActorId manager,
                           td::Timestamp timeout, td::Promise promise, bool skip_check_signatures = false);
void run_check_proof_query(BlockIdExt id, td::Ref proof, td::actor::ActorId manager,
                           td::Timestamp timeout, td::Promise promise,
                           td::Ref rel_masterchain_state, bool skip_check_signatures = false);
void run_check_proof_query(BlockIdExt id, td::Ref proof, td::actor::ActorId manager,
                           td::Timestamp timeout, td::Promise promise,
                           td::Ref rel_key_block_proof, bool skip_check_signatures = false);
void run_check_proof_link_query(BlockIdExt id, td::Ref proof, td::actor::ActorId manager,
                                td::Timestamp timeout, td::Promise promise);
void run_validate_query(ShardIdFull shard, BlockIdExt min_masterchain_block_id, std::vector prev,
                        BlockCandidate candidate, td::Ref validator_set,
                        td::actor::ActorId manager, td::Timestamp timeout,
                        td::Promise promise, bool is_fake = false);
void run_collate_query(ShardIdFull shard, const BlockIdExt& min_masterchain_block_id, std::vector prev,
                       Ed25519_PublicKey creator, td::Ref validator_set,
                       td::Ref collator_opts, td::actor::ActorId manager,
                       td::Timestamp timeout, td::Promise promise,
                       td::CancellationToken cancellation_token, unsigned mode, int attempt_idx = 0);
void run_collate_hardfork(ShardIdFull shard, const BlockIdExt& min_masterchain_block_id, std::vector prev,
                          td::actor::ActorId manager, td::Timestamp timeout,
                          td::Promise promise);
void run_liteserver_query(td::BufferSlice data, td::actor::ActorId manager,
                          td::actor::ActorId cache, td::Promise promise);
void run_fetch_account_state(WorkchainId wc, StdSmcAddress  addr, td::actor::ActorId manager,
                             td::Promise,UnixTime,LogicalTime,std::unique_ptr>> promise);
void run_validate_shard_block_description(td::BufferSlice data, BlockHandle masterchain_block,
                                          td::Ref masterchain_state,
                                          td::actor::ActorId manager, td::Timestamp timeout,
                                          td::Promise> promise, bool is_fake = false);
}  // namespace validator
}  // namespace ton