Kagome
Polkadot Runtime Engine in C++17
kagome::offchain::OffchainWorkerImpl Class Referencefinal

#include <offchain_worker_impl.hpp>

Inheritance diagram for kagome::offchain::OffchainWorkerImpl:
Collaboration diagram for kagome::offchain::OffchainWorkerImpl:

Public Member Functions

 OffchainWorkerImpl (const application::AppConfiguration &app_config, std::shared_ptr< clock::SystemClock > clock, std::shared_ptr< crypto::Hasher > hasher, std::shared_ptr< storage::BufferStorage > storage, std::shared_ptr< crypto::CSPRNG > random_generator, std::shared_ptr< api::AuthorApi > author_api, const network::OwnPeerInfo &current_peer_info, std::shared_ptr< OffchainPersistentStorage > persistent_storage, std::shared_ptr< runtime::Executor > executor, const primitives::BlockHeader &header, std::shared_ptr< OffchainWorkerPool > ocw_pool)
 
outcome::result< void > run () override
 
bool isValidator () const override
 
Result< Success, FailuresubmitTransaction (const primitives::Extrinsic &ext) override
 
Result< OpaqueNetworkState, FailurenetworkState () override
 
Timestamp timestamp () override
 
void sleepUntil (Timestamp timestamp) override
 
RandomSeed randomSeed () override
 
void localStorageSet (StorageType storage_type, const common::BufferView &key, common::Buffer value) override
 
void localStorageClear (StorageType storage_type, const common::BufferView &key) override
 
bool localStorageCompareAndSet (StorageType storage_type, const common::BufferView &key, std::optional< common::BufferView > expected, common::Buffer value) override
 
outcome::result< common::BufferlocalStorageGet (StorageType storage_type, const common::BufferView &key) override
 
Result< RequestId, FailurehttpRequestStart (HttpMethod method, std::string_view uri, common::Buffer meta) override
 
Result< Success, FailurehttpRequestAddHeader (RequestId id, std::string_view name, std::string_view value) override
 
Result< Success, HttpErrorhttpRequestWriteBody (RequestId id, common::Buffer chunk, std::optional< Timestamp > deadline) override
 
std::vector< HttpStatushttpResponseWait (const std::vector< RequestId > &ids, std::optional< Timestamp > deadline) override
 
std::vector< std::pair< std::string, std::string > > httpResponseHeaders (RequestId id) override
 
Result< uint32_t, HttpErrorhttpResponseReadBody (RequestId id, common::Buffer &chunk, std::optional< Timestamp > deadline) override
 
void setAuthorizedNodes (std::vector< libp2p::peer::PeerId > nodes, bool authorized_only) override
 
- Public Member Functions inherited from kagome::offchain::OffchainWorker
virtual ~OffchainWorker ()=default
 

Static Public Attributes

static constexpr auto latency_of_waiting = 1ms
 

Private Member Functions

OffchainStoragegetStorage (StorageType storage_type)
 

Private Attributes

const application::AppConfigurationapp_config_
 
std::shared_ptr< clock::SystemClockclock_
 
std::shared_ptr< crypto::Hasherhasher_
 
std::shared_ptr< crypto::CSPRNGrandom_generator_
 
std::shared_ptr< api::AuthorApiauthor_api_
 
const network::OwnPeerInfocurrent_peer_info_
 
std::shared_ptr< offchain::OffchainPersistentStoragepersistent_storage_
 
std::shared_ptr< offchain::OffchainLocalStoragelocal_storage_
 
std::shared_ptr< runtime::Executorexecutor_
 
const primitives::BlockHeader header_
 
const primitives::BlockInfo block_
 
std::shared_ptr< OffchainWorkerPoolocw_pool_
 
log::Logger log_
 
int16_t request_id_ = 0
 
std::map< RequestId, std::shared_ptr< HttpRequest > > active_http_requests_
 

Detailed Description

Definition at line 38 of file offchain_worker_impl.hpp.

Constructor & Destructor Documentation

kagome::offchain::OffchainWorkerImpl::OffchainWorkerImpl ( const application::AppConfiguration app_config,
std::shared_ptr< clock::SystemClock clock,
std::shared_ptr< crypto::Hasher hasher,
std::shared_ptr< storage::BufferStorage storage,
std::shared_ptr< crypto::CSPRNG random_generator,
std::shared_ptr< api::AuthorApi author_api,
const network::OwnPeerInfo current_peer_info,
std::shared_ptr< OffchainPersistentStorage persistent_storage,
std::shared_ptr< runtime::Executor executor,
const primitives::BlockHeader header,
std::shared_ptr< OffchainWorkerPool ocw_pool 
)

Definition at line 22 of file offchain_worker_impl.cpp.

Member Function Documentation

offchain::OffchainStorage & kagome::offchain::OffchainWorkerImpl::getStorage ( StorageType  storage_type)
private

Definition at line 152 of file offchain_worker_impl.cpp.

Result< Success, Failure > kagome::offchain::OffchainWorkerImpl::httpRequestAddHeader ( RequestId  id,
std::string_view  name,
std::string_view  value 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 240 of file offchain_worker_impl.cpp.

Result< RequestId, Failure > kagome::offchain::OffchainWorkerImpl::httpRequestStart ( HttpMethod  method,
std::string_view  uri,
common::Buffer  meta 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 221 of file offchain_worker_impl.cpp.

Result< Success, HttpError > kagome::offchain::OffchainWorkerImpl::httpRequestWriteBody ( RequestId  id,
common::Buffer  chunk,
std::optional< Timestamp deadline 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 253 of file offchain_worker_impl.cpp.

std::vector< std::pair< std::string, std::string > > kagome::offchain::OffchainWorkerImpl::httpResponseHeaders ( RequestId  id)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 303 of file offchain_worker_impl.cpp.

Result< uint32_t, HttpError > kagome::offchain::OffchainWorkerImpl::httpResponseReadBody ( RequestId  id,
common::Buffer chunk,
std::optional< Timestamp deadline 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 316 of file offchain_worker_impl.cpp.

std::vector< HttpStatus > kagome::offchain::OffchainWorkerImpl::httpResponseWait ( const std::vector< RequestId > &  ids,
std::optional< Timestamp deadline 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 273 of file offchain_worker_impl.cpp.

bool kagome::offchain::OffchainWorkerImpl::isValidator ( ) const
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 103 of file offchain_worker_impl.cpp.

void kagome::offchain::OffchainWorkerImpl::localStorageClear ( StorageType  storage_type,
const common::BufferView key 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 184 of file offchain_worker_impl.cpp.

bool kagome::offchain::OffchainWorkerImpl::localStorageCompareAndSet ( StorageType  storage_type,
const common::BufferView key,
std::optional< common::BufferView expected,
common::Buffer  value 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 194 of file offchain_worker_impl.cpp.

outcome::result< common::Buffer > kagome::offchain::OffchainWorkerImpl::localStorageGet ( StorageType  storage_type,
const common::BufferView key 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 210 of file offchain_worker_impl.cpp.

void kagome::offchain::OffchainWorkerImpl::localStorageSet ( StorageType  storage_type,
const common::BufferView key,
common::Buffer  value 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 174 of file offchain_worker_impl.cpp.

Result< OpaqueNetworkState, Failure > kagome::offchain::OffchainWorkerImpl::networkState ( )
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 118 of file offchain_worker_impl.cpp.

RandomSeed kagome::offchain::OffchainWorkerImpl::randomSeed ( )
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 146 of file offchain_worker_impl.cpp.

outcome::result< void > kagome::offchain::OffchainWorkerImpl::run ( )
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 63 of file offchain_worker_impl.cpp.

void kagome::offchain::OffchainWorkerImpl::setAuthorizedNodes ( std::vector< libp2p::peer::PeerId >  nodes,
bool  authorized_only 
)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 336 of file offchain_worker_impl.cpp.

void kagome::offchain::OffchainWorkerImpl::sleepUntil ( Timestamp  timestamp)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 132 of file offchain_worker_impl.cpp.

Result< Success, Failure > kagome::offchain::OffchainWorkerImpl::submitTransaction ( const primitives::Extrinsic ext)
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 108 of file offchain_worker_impl.cpp.

Timestamp kagome::offchain::OffchainWorkerImpl::timestamp ( )
overridevirtual

Implements kagome::offchain::OffchainWorker.

Definition at line 126 of file offchain_worker_impl.cpp.

Member Data Documentation

std::map<RequestId, std::shared_ptr<HttpRequest> > kagome::offchain::OffchainWorkerImpl::active_http_requests_
private

Definition at line 134 of file offchain_worker_impl.hpp.

const application::AppConfiguration& kagome::offchain::OffchainWorkerImpl::app_config_
private

Definition at line 119 of file offchain_worker_impl.hpp.

std::shared_ptr<api::AuthorApi> kagome::offchain::OffchainWorkerImpl::author_api_
private

Definition at line 123 of file offchain_worker_impl.hpp.

const primitives::BlockInfo kagome::offchain::OffchainWorkerImpl::block_
private

Definition at line 129 of file offchain_worker_impl.hpp.

std::shared_ptr<clock::SystemClock> kagome::offchain::OffchainWorkerImpl::clock_
private

Definition at line 120 of file offchain_worker_impl.hpp.

const network::OwnPeerInfo& kagome::offchain::OffchainWorkerImpl::current_peer_info_
private

Definition at line 124 of file offchain_worker_impl.hpp.

std::shared_ptr<runtime::Executor> kagome::offchain::OffchainWorkerImpl::executor_
private

Definition at line 127 of file offchain_worker_impl.hpp.

std::shared_ptr<crypto::Hasher> kagome::offchain::OffchainWorkerImpl::hasher_
private

Definition at line 121 of file offchain_worker_impl.hpp.

const primitives::BlockHeader kagome::offchain::OffchainWorkerImpl::header_
private

Definition at line 128 of file offchain_worker_impl.hpp.

constexpr auto kagome::offchain::OffchainWorkerImpl::latency_of_waiting = 1ms
static

Definition at line 44 of file offchain_worker_impl.hpp.

std::shared_ptr<offchain::OffchainLocalStorage> kagome::offchain::OffchainWorkerImpl::local_storage_
private

Definition at line 126 of file offchain_worker_impl.hpp.

log::Logger kagome::offchain::OffchainWorkerImpl::log_
private

Definition at line 131 of file offchain_worker_impl.hpp.

std::shared_ptr<OffchainWorkerPool> kagome::offchain::OffchainWorkerImpl::ocw_pool_
private

Definition at line 130 of file offchain_worker_impl.hpp.

std::shared_ptr<offchain::OffchainPersistentStorage> kagome::offchain::OffchainWorkerImpl::persistent_storage_
private

Definition at line 125 of file offchain_worker_impl.hpp.

std::shared_ptr<crypto::CSPRNG> kagome::offchain::OffchainWorkerImpl::random_generator_
private

Definition at line 122 of file offchain_worker_impl.hpp.

int16_t kagome::offchain::OffchainWorkerImpl::request_id_ = 0
private

Definition at line 133 of file offchain_worker_impl.hpp.


The documentation for this class was generated from the following files: