mirror of
				https://github.com/ton-blockchain/ton
				synced 2025-03-09 15:40:10 +00:00 
			
		
		
		
	* Deferred messages and msg metadata * Store out msg queue size in state * Add checks for queue processing 1. Collator must process at least one message from AccountDispatchQueue (unless block is full) 2. The first message from a transaction is not counted, it cannot be deferred (unless AccountDispatchQueue is not empty) * Return msg metadata from LS in listBlockTransactions[Ext] * Enable new features by capabilities * Changes in deferred messages * Process deferred messages via new_msgs in collator * Rework setting deferred_lt, bring back check_message_processing_order, check order of deferred_lt in validator * Use have_unprocessed_account_dispatch_queue_ in collator * Fix setting transaction lt for deferred messages * Fix lite-client compilation error * Changes in process_dispatch_queue, rename deferred_lt -> emitted_lt * Fix compilation error * Use uint64 for msg queue size * Add liteServer.getBlockOutMsgQueueSize * Fix compilation error * Fix typos in comments --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
		
			
				
	
	
		
			122 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			122 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
    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 <http://www.gnu.org/licenses/>.
 | 
						|
 | 
						|
    Copyright 2017-2020 Telegram Systems LLP
 | 
						|
*/
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include "td/utils/common.h"
 | 
						|
#include "td/utils/Status.h"
 | 
						|
 | 
						|
#include <type_traits>
 | 
						|
#include <utility>
 | 
						|
 | 
						|
namespace td {
 | 
						|
 | 
						|
template <class T, bool = std::is_copy_constructible<T>::value>
 | 
						|
class optional {
 | 
						|
 public:
 | 
						|
  optional() = default;
 | 
						|
  template <class T1,
 | 
						|
            std::enable_if_t<!std::is_same<std::decay_t<T1>, optional>::value && std::is_constructible<T, T1>::value,
 | 
						|
                             int> = 0>
 | 
						|
  optional(T1 &&t) : impl_(std::forward<T1>(t)) {
 | 
						|
  }
 | 
						|
 | 
						|
  optional(const optional &other) {
 | 
						|
    if (other) {
 | 
						|
      impl_ = Result<T>(other.value());
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  optional &operator=(const optional &other) {
 | 
						|
    if (other) {
 | 
						|
      impl_ = Result<T>(other.value());
 | 
						|
    } else {
 | 
						|
      impl_ = Result<T>();
 | 
						|
    }
 | 
						|
    return *this;
 | 
						|
  }
 | 
						|
 | 
						|
  optional(optional &&other) = default;
 | 
						|
  optional &operator=(optional &&other) = default;
 | 
						|
  ~optional() = default;
 | 
						|
 | 
						|
  explicit operator bool() const {
 | 
						|
    return impl_.is_ok();
 | 
						|
  }
 | 
						|
  T &value() {
 | 
						|
    DCHECK(*this);
 | 
						|
    return impl_.ok_ref();
 | 
						|
  }
 | 
						|
  const T &value() const {
 | 
						|
    DCHECK(*this);
 | 
						|
    return impl_.ok_ref();
 | 
						|
  }
 | 
						|
  T &value_force() {
 | 
						|
    if (!*this) {
 | 
						|
      *this = T();
 | 
						|
    }
 | 
						|
    return value();
 | 
						|
  }
 | 
						|
  T &operator*() {
 | 
						|
    return value();
 | 
						|
  }
 | 
						|
  T unwrap() {
 | 
						|
    CHECK(*this);
 | 
						|
    auto res = std::move(value());
 | 
						|
    impl_ = {};
 | 
						|
    return res;
 | 
						|
  }
 | 
						|
 | 
						|
  td::optional<T> copy() const {
 | 
						|
    if (*this) {
 | 
						|
      return value();
 | 
						|
    }
 | 
						|
    return {};
 | 
						|
  }
 | 
						|
 | 
						|
  template <class... ArgsT>
 | 
						|
  void emplace(ArgsT &&... args) {
 | 
						|
    impl_.emplace(std::forward<ArgsT>(args)...);
 | 
						|
  }
 | 
						|
 | 
						|
  bool operator==(const optional& other) const {
 | 
						|
    return (bool)*this == (bool)other && (!(bool)*this || value() == other.value());
 | 
						|
  }
 | 
						|
 | 
						|
  bool operator!=(const optional& other) const {
 | 
						|
    return !(*this == other);
 | 
						|
  }
 | 
						|
 | 
						|
 private:
 | 
						|
  Result<T> impl_;
 | 
						|
};
 | 
						|
 | 
						|
template <typename T>
 | 
						|
struct optional<T, false> : optional<T, true> {
 | 
						|
  optional() = default;
 | 
						|
 | 
						|
  using optional<T, true>::optional;
 | 
						|
 | 
						|
  optional(const optional &other) = delete;
 | 
						|
  optional &operator=(const optional &other) = delete;
 | 
						|
  optional(optional &&) = default;
 | 
						|
  optional &operator=(optional &&) = default;
 | 
						|
  ~optional() = default;
 | 
						|
};
 | 
						|
 | 
						|
}  // namespace td
 |