6 #ifndef KAGOME_OFFCHAIN_OFFCHAINWORKERIMPL 7 #define KAGOME_OFFCHAIN_OFFCHAINWORKERIMPL 11 #include <boost/asio/io_context.hpp> 25 class AppConfiguration;
36 class OffchainWorkerPool;
40 public std::enable_shared_from_this<OffchainWorkerImpl> {
44 static constexpr
auto latency_of_waiting = 1ms;
48 std::shared_ptr<clock::SystemClock> clock,
49 std::shared_ptr<crypto::Hasher> hasher,
50 std::shared_ptr<storage::BufferStorage> storage,
51 std::shared_ptr<crypto::CSPRNG> random_generator,
52 std::shared_ptr<api::AuthorApi> author_api,
54 std::shared_ptr<OffchainPersistentStorage> persistent_storage,
55 std::shared_ptr<runtime::Executor> executor,
57 std::shared_ptr<OffchainWorkerPool> ocw_pool);
59 outcome::result<void> run()
override;
61 bool isValidator()
const override;
70 void sleepUntil(
Timestamp timestamp)
override;
81 bool localStorageCompareAndSet(
StorageType storage_type,
83 std::optional<common::BufferView> expected,
86 outcome::result<common::Buffer> localStorageGet(
94 RequestId id, std::string_view name, std::string_view value)
override;
99 std::optional<Timestamp> deadline)
override;
101 std::vector<HttpStatus> httpResponseWait(
102 const std::vector<RequestId> &ids,
103 std::optional<Timestamp> deadline)
override;
105 std::vector<std::pair<std::string, std::string>> httpResponseHeaders(
111 std::optional<Timestamp> deadline)
override;
113 void setAuthorizedNodes(std::vector<libp2p::peer::PeerId> nodes,
114 bool authorized_only)
override;
120 std::shared_ptr<clock::SystemClock>
clock_;
133 int16_t request_id_ = 0;
139 #endif // KAGOME_OFFCHAIN_OFFCHAINWORKERIMPL
Class represents arbitrary (including empty) byte buffer.
std::map< RequestId, std::shared_ptr< HttpRequest > > active_http_requests_
std::shared_ptr< api::AuthorApi > author_api_
std::shared_ptr< OffchainWorkerPool > ocw_pool_
const network::OwnPeerInfo & current_peer_info_
const primitives::BlockHeader header_
std::shared_ptr< soralog::Logger > Logger
std::shared_ptr< crypto::Hasher > hasher_
uint64_t Timestamp
Timestamp is milliseconds since UNIX Epoch.
std::shared_ptr< crypto::CSPRNG > random_generator_
std::shared_ptr< offchain::OffchainLocalStorage > local_storage_
std::shared_ptr< clock::SystemClock > clock_
Extrinsic class represents extrinsic.
const primitives::BlockInfo block_
const application::AppConfiguration & app_config_
std::shared_ptr< offchain::OffchainPersistentStorage > persistent_storage_
std::shared_ptr< runtime::Executor > executor_