Node

Trait Node 

Source
pub trait Node: Send + Sync {
Show 29 methods // Required methods fn parameters<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<VersionedParameters>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn best_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_best_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<BlockDesc>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn finalized_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_finalized_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<BlockDesc>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn parent<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn state_root<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<StateRootHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn beefy_root<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<MmrPeakHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn encoded_statistics<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<Bytes>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_encoded_statistics<'life0, 'async_trait>( &'life0 self, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Bytes>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn encoded_service_data<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_encoded_service_data<'life0, 'async_trait>( &'life0 self, id: ServiceId, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn service_value<'life0, 'life1, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn subscribe_service_value<'life0, 'life1, 'async_trait>( &'life0 self, id: ServiceId, key: &'life1 [u8], finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn service_preimage<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, hash: Hash, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_service_preimage<'life0, 'async_trait>( &'life0 self, id: ServiceId, hash: Hash, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn service_request<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, hash: Hash, len: u32, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Vec<Slot>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_service_request<'life0, 'async_trait>( &'life0 self, id: ServiceId, hash: Hash, len: u32, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Vec<Slot>>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn work_report<'life0, 'async_trait>( &'life0 self, hash: WorkReportHash, ) -> Pin<Box<dyn Future<Output = NodeResult<WorkReport>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn submit_encoded_work_package<'life0, 'life1, 'async_trait>( &'life0 self, core: CoreIndex, package: Bytes, extrinsics: &'life1 [Bytes], ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn submit_encoded_work_package_bundle<'life0, 'async_trait>( &'life0 self, core: CoreIndex, bundle: Bytes, ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn work_package_status<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, hash: WorkPackageHash, anchor: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<WorkPackageStatus>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_work_package_status<'life0, 'async_trait>( &'life0 self, hash: WorkPackageHash, anchor: HeaderHash, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, WorkPackageStatus>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn submit_preimage<'life0, 'async_trait>( &'life0 self, requester: ServiceId, preimage: Bytes, ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn list_services<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<ServiceId>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn fetch_work_package_segments<'life0, 'async_trait>( &'life0 self, wp_hash: WorkPackageHash, indices: Vec<u16>, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<Segment>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn fetch_segments<'life0, 'async_trait>( &'life0 self, segment_root: SegmentTreeRoot, indices: Vec<u16>, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<Segment>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sync_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<SyncState>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn subscribe_sync_status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<SyncStatus>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Generic JAM node interface.

This trait is implemented directly by eg PolkaJam, and is also implemented for all types implementing RpcClient. JAM tools and builders should ideally use this trait internally, so that they can support both embedded nodes as well as RPC.

§Chain subscriptions

The subscribe methods which return a ChainSub all take a finalized argument. This argument determines which chain to track: if finalized is true, the subscription tracks the latest finalized block; if finalized is false, the subscription tracks the head of the “best” chain.

Note that as the “best” chain may switch to a different fork at any time:

  • Updates yielded by a subscription following the best chain are not guaranteed to ever be included in the finalized chain.
  • Subscriptions following the best chain may yield “impossible” update sequences. For example, subscribe_work_package_status(finalized: false) may yield a Reported status followed by a Reportable status, if the best chain switches from a fork where the package has been reported to a fork where it has not.

If these behaviours are unacceptable, use subscriptions tracking the latest finalized block instead. Such subscriptions are well-behaved, but may be significantly delayed compared to best-chain subscriptions.

Required Methods§

Source

fn parameters<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<VersionedParameters>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the chain parameters.

Source

fn best_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the header hash and slot of the head of the “best” chain.

Source

fn subscribe_best_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<BlockDesc>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the head of the “best” chain, as returned by best_block.

Source

fn finalized_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the header hash and slot of the latest finalized block.

Source

fn subscribe_finalized_block<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<BlockDesc>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the latest finalized block, as returned by finalized_block.

Source

fn parent<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<BlockDesc>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the header hash and slot of the parent of the block with the given header hash.

Source

fn state_root<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<StateRootHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the posterior state root of the block with the given header hash.

Source

fn beefy_root<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<MmrPeakHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the BEEFY root of the block with the given header hash.

Source

fn encoded_statistics<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the activity statistics stored in the posterior state of the block with the given header hash.

The statistics are encoded as per the GP.

Source

fn subscribe_encoded_statistics<'life0, 'async_trait>( &'life0 self, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the activity statistics stored in chain state.

The statistics are encoded as per the GP.

Source

fn encoded_service_data<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the storage data for the service with the given ID.

The data are encoded as per the GP. None is returned if there is no service with the given ID.

Source

fn subscribe_encoded_service_data<'life0, 'async_trait>( &'life0 self, id: ServiceId, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the storage data for the service with the given ID.

The value field of updates will contain service data encoded as per the GP. It will be None when there is no service with the given ID.

Source

fn service_value<'life0, 'life1, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the value associated with the given service ID and key in the posterior state of the block with the given header hash.

None is returned if there is no value associated with the given service ID and key.

This method can be used to query arbitrary key-value pairs set by service accumulation logic.

Source

fn subscribe_service_value<'life0, 'life1, 'async_trait>( &'life0 self, id: ServiceId, key: &'life1 [u8], finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to updates of the value associated with the given service ID and key.

The value field of updates will be None when there is no value associated with the given service ID and key.

Source

fn service_preimage<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, hash: Hash, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the preimage of the given hash, if it has been provided to the given service in the posterior state of the block with the given header hash.

None is returned if the preimage has not been provided to the given service.

Source

fn subscribe_service_preimage<'life0, 'async_trait>( &'life0 self, id: ServiceId, hash: Hash, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Bytes>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the preimage associated with the given service ID and hash.

The value field of updates will be None if the preimage has not been provided to the service. Otherwise, it will be the preimage of the given hash.

Source

fn service_request<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, id: ServiceId, hash: Hash, len: u32, ) -> Pin<Box<dyn Future<Output = NodeResult<Option<Vec<Slot>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the preimage request associated with the given service ID and hash/length in the posterior state of the block with the given header hash.

None is returned if the preimage with the given hash/length has neither been requested by nor provided to the given service. An empty list is returned if the preimage has been requested, but not yet provided. A non-empty list means that the preimage has been provided; the meaning of the slots in the list is as follows:

  • The first slot is the slot in which the preimage was provided.
  • The second slot, if present, is the slot in which the preimage was “forgotten”.
  • The third slot, if present, is the slot in which the preimage was requested again.
Source

fn subscribe_service_request<'life0, 'async_trait>( &'life0 self, id: ServiceId, hash: Hash, len: u32, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, Option<Vec<Slot>>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates of the preimage request associated with the given service ID and hash/length.

The value field of updates will either be None or a list of slots, with the same semantics as service_request return values.

Source

fn work_report<'life0, 'async_trait>( &'life0 self, hash: WorkReportHash, ) -> Pin<Box<dyn Future<Output = NodeResult<WorkReport>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the work-report with the given hash.

Source

fn submit_encoded_work_package<'life0, 'life1, 'async_trait>( &'life0 self, core: CoreIndex, package: Bytes, extrinsics: &'life1 [Bytes], ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Submit a work-package to the guarantors currently assigned to the given core.

Source

fn submit_encoded_work_package_bundle<'life0, 'async_trait>( &'life0 self, core: CoreIndex, bundle: Bytes, ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submit a work-package bundle to the guarantors currently assigned to the given core.

Source

fn work_package_status<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, hash: WorkPackageHash, anchor: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<WorkPackageStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the status of the given work-package following execution of the block with the given header hash.

If anchor does not match the anchor of the work-package then an error or an incorrect status may be returned. An error may be returned if anchor is too old.

Source

fn subscribe_work_package_status<'life0, 'async_trait>( &'life0 self, hash: WorkPackageHash, anchor: HeaderHash, finalized: bool, ) -> Pin<Box<dyn Future<Output = NodeResult<ChainSub<'_, WorkPackageStatus>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to status updates for the given work-package.

If anchor does not match the anchor of the work-package then the subscription may fail or yield incorrect statuses. The subscription may fail if anchor is too old.

Source

fn submit_preimage<'life0, 'async_trait>( &'life0 self, requester: ServiceId, preimage: Bytes, ) -> Pin<Box<dyn Future<Output = NodeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submit a preimage which is being requested by the given service.

Note that this method does not wait for the preimage to be distributed or integrated on-chain; it returns immediately.

Source

fn list_services<'life0, 'async_trait>( &'life0 self, header_hash: HeaderHash, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<ServiceId>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a list of all services currently known to be on JAM.

This is a best-effort list and may not reflect the true state. Nodes could e.g. reasonably hide services which are not recently active from this list.

Source

fn fetch_work_package_segments<'life0, 'async_trait>( &'life0 self, wp_hash: WorkPackageHash, indices: Vec<u16>, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<Segment>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches a list of segments from the DA layer, exported by the work-package with the given hash.

Source

fn fetch_segments<'life0, 'async_trait>( &'life0 self, segment_root: SegmentTreeRoot, indices: Vec<u16>, ) -> Pin<Box<dyn Future<Output = NodeResult<Vec<Segment>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches a list of segments from the DA layer, exported by a work-package with the given segment root hash.

Source

fn sync_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<SyncState>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the sync status of the node.

Source

fn subscribe_sync_status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = NodeResult<BoxStream<'_, NodeResult<SyncStatus>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to changes in sync status.

Implementors§

Source§

impl<T: RpcClient + Send + Sync> Node for T