Kagome
Polkadot Runtime Engine in C++17
kagome::offchain::OffchainWorker Class Referenceabstract

#include <offchain_worker.hpp>

Inheritance diagram for kagome::offchain::OffchainWorker:
Collaboration diagram for kagome::offchain::OffchainWorker:

Public Member Functions

virtual ~OffchainWorker ()=default
 
virtual outcome::result< void > run ()=0
 
virtual bool isValidator () const =0
 
virtual Result< Success, FailuresubmitTransaction (const primitives::Extrinsic &ext)=0
 
virtual Result< OpaqueNetworkState, FailurenetworkState ()=0
 
virtual Timestamp timestamp ()=0
 
virtual void sleepUntil (Timestamp)=0
 
virtual RandomSeed randomSeed ()=0
 
virtual void localStorageSet (StorageType storage_type, const common::BufferView &key, common::Buffer value)=0
 
virtual void localStorageClear (StorageType storage_type, const common::BufferView &key)=0
 
virtual bool localStorageCompareAndSet (StorageType storage_type, const common::BufferView &key, std::optional< common::BufferView > expected, common::Buffer value)=0
 
virtual outcome::result< common::BufferlocalStorageGet (StorageType storage_type, const common::BufferView &key)=0
 
virtual Result< RequestId, FailurehttpRequestStart (HttpMethod method, std::string_view uri, common::Buffer meta)=0
 
virtual Result< Success, FailurehttpRequestAddHeader (RequestId id, std::string_view name, std::string_view value)=0
 
virtual Result< Success, HttpErrorhttpRequestWriteBody (RequestId id, common::Buffer chunk, std::optional< Timestamp > deadline)=0
 
virtual std::vector< HttpStatushttpResponseWait (const std::vector< RequestId > &ids, std::optional< Timestamp > deadline)=0
 
virtual std::vector< std::pair< std::string, std::string > > httpResponseHeaders (RequestId id)=0
 
virtual Result< uint32_t, HttpErrorhttpResponseReadBody (RequestId id, common::Buffer &chunk, std::optional< Timestamp > deadline)=0
 
virtual void setAuthorizedNodes (std::vector< libp2p::peer::PeerId > nodes, bool authorized_only)=0
 

Detailed Description

The offchain workers allow the execution of long-running and possibly non-deterministic tasks (e.g. web requests, encryption/decryption and signing of data, random number generation, CPU-intensive computations, enumeration/aggregation of on-chain data, etc.) which could otherwise require longer than the block execution time. Offchain workers have their own execution environment. This separation of concerns is to make sure that the block production is not impacted by the long-running tasks.

Definition at line 31 of file offchain_worker.hpp.

Constructor & Destructor Documentation

virtual kagome::offchain::OffchainWorker::~OffchainWorker ( )
virtualdefault

Member Function Documentation

virtual Result<Success, Failure> kagome::offchain::OffchainWorker::httpRequestAddHeader ( RequestId  id,
std::string_view  name,
std::string_view  value 
)
pure virtual
virtual Result<RequestId, Failure> kagome::offchain::OffchainWorker::httpRequestStart ( HttpMethod  method,
std::string_view  uri,
common::Buffer  meta 
)
pure virtual
virtual Result<Success, HttpError> kagome::offchain::OffchainWorker::httpRequestWriteBody ( RequestId  id,
common::Buffer  chunk,
std::optional< Timestamp deadline 
)
pure virtual
virtual std::vector<std::pair<std::string, std::string> > kagome::offchain::OffchainWorker::httpResponseHeaders ( RequestId  id)
pure virtual
virtual Result<uint32_t, HttpError> kagome::offchain::OffchainWorker::httpResponseReadBody ( RequestId  id,
common::Buffer chunk,
std::optional< Timestamp deadline 
)
pure virtual
virtual std::vector<HttpStatus> kagome::offchain::OffchainWorker::httpResponseWait ( const std::vector< RequestId > &  ids,
std::optional< Timestamp deadline 
)
pure virtual
virtual bool kagome::offchain::OffchainWorker::isValidator ( ) const
pure virtual
virtual void kagome::offchain::OffchainWorker::localStorageClear ( StorageType  storage_type,
const common::BufferView key 
)
pure virtual
virtual bool kagome::offchain::OffchainWorker::localStorageCompareAndSet ( StorageType  storage_type,
const common::BufferView key,
std::optional< common::BufferView expected,
common::Buffer  value 
)
pure virtual
virtual outcome::result<common::Buffer> kagome::offchain::OffchainWorker::localStorageGet ( StorageType  storage_type,
const common::BufferView key 
)
pure virtual
virtual void kagome::offchain::OffchainWorker::localStorageSet ( StorageType  storage_type,
const common::BufferView key,
common::Buffer  value 
)
pure virtual
virtual Result<OpaqueNetworkState, Failure> kagome::offchain::OffchainWorker::networkState ( )
pure virtual
virtual RandomSeed kagome::offchain::OffchainWorker::randomSeed ( )
pure virtual
virtual outcome::result<void> kagome::offchain::OffchainWorker::run ( )
pure virtual
virtual void kagome::offchain::OffchainWorker::setAuthorizedNodes ( std::vector< libp2p::peer::PeerId >  nodes,
bool  authorized_only 
)
pure virtual
virtual void kagome::offchain::OffchainWorker::sleepUntil ( Timestamp  )
pure virtual
virtual Result<Success, Failure> kagome::offchain::OffchainWorker::submitTransaction ( const primitives::Extrinsic ext)
pure virtual
virtual Timestamp kagome::offchain::OffchainWorker::timestamp ( )
pure virtual

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