Struct sc_light::blockchain::Blockchain
source · [−]pub struct Blockchain<S> { /* private fields */ }
Expand description
Light client blockchain.
Implementations
sourceimpl<S> Blockchain<S>
impl<S> Blockchain<S>
Trait Implementations
sourceimpl<S, Block> Backend<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
impl<S, Block> Backend<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
sourcefn body(
&self,
_id: BlockId<Block>
) -> ClientResult<Option<Vec<Block::Extrinsic>>>
fn body(
&self,
_id: BlockId<Block>
) -> ClientResult<Option<Vec<Block::Extrinsic>>>
Get block body. Returns None
if block is not found.
sourcefn justification(
&self,
_id: BlockId<Block>
) -> ClientResult<Option<Justification>>
fn justification(
&self,
_id: BlockId<Block>
) -> ClientResult<Option<Justification>>
Get block justification. Returns None
if justification does not exist.
sourcefn last_finalized(&self) -> ClientResult<Block::Hash>
fn last_finalized(&self) -> ClientResult<Block::Hash>
Get last finalized block hash.
sourcefn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>>
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>>
Returns data cache reference, if it is enabled on this backend.
sourcefn leaves(&self) -> ClientResult<Vec<Block::Hash>>
fn leaves(&self) -> ClientResult<Vec<Block::Hash>>
Returns hashes of all blocks that are leaves of the block tree. in other words, that have no children, are chain heads. Results must be ordered best (longest, highest) chain first. Read more
sourcefn children(&self, _parent_hash: Block::Hash) -> ClientResult<Vec<Block::Hash>>
fn children(&self, _parent_hash: Block::Hash) -> ClientResult<Vec<Block::Hash>>
Return hashes of all blocks that are children of the block with parent_hash
.
sourcefn extrinsic(
&self,
_hash: &Block::Hash
) -> ClientResult<Option<<Block as BlockT>::Extrinsic>>
fn extrinsic(
&self,
_hash: &Block::Hash
) -> ClientResult<Option<<Block as BlockT>::Extrinsic>>
Get single extrinsic by hash.
sourcefn best_containing(
&self,
target_hash: <Block as Block>::Hash,
maybe_max_number: Option<<<Block as Block>::Header as Header>::Number>,
import_lock: &RwLock<RawRwLock, ()>
) -> Result<Option<<Block as Block>::Hash>, Error>
fn best_containing(
&self,
target_hash: <Block as Block>::Hash,
maybe_max_number: Option<<<Block as Block>::Header as Header>::Number>,
import_lock: &RwLock<RawRwLock, ()>
) -> Result<Option<<Block as Block>::Hash>, Error>
Get the most recent block hash of the best (longest) chains
that contain block with the given target_hash
. Read more
sourceimpl<S, Block> HeaderBackend<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
impl<S, Block> HeaderBackend<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
sourcefn header(&self, id: BlockId<Block>) -> ClientResult<Option<Block::Header>>
fn header(&self, id: BlockId<Block>) -> ClientResult<Option<Block::Header>>
Get block header. Returns None
if block is not found.
sourcefn info(&self) -> BlockchainInfo<Block>
fn info(&self) -> BlockchainInfo<Block>
Get blockchain info.
sourcefn status(&self, id: BlockId<Block>) -> ClientResult<BlockStatus>
fn status(&self, id: BlockId<Block>) -> ClientResult<BlockStatus>
Get block status.
sourcefn number(&self, hash: Block::Hash) -> ClientResult<Option<NumberFor<Block>>>
fn number(&self, hash: Block::Hash) -> ClientResult<Option<NumberFor<Block>>>
Get block number by hash. Returns None
if the header is not in the chain.
sourcefn hash(
&self,
number: <<Block as BlockT>::Header as HeaderT>::Number
) -> ClientResult<Option<Block::Hash>>
fn hash(
&self,
number: <<Block as BlockT>::Header as HeaderT>::Number
) -> ClientResult<Option<Block::Hash>>
Get block hash by number. Returns None
if the header is not in the chain.
sourcefn block_hash_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<<Block as Block>::Hash>, Error>
fn block_hash_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<<Block as Block>::Hash>, Error>
Convert an arbitrary block ID into a block hash.
sourcefn block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>
fn block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>
Convert an arbitrary block ID into a block hash.
sourcefn expect_header(
&self,
id: BlockId<Block>
) -> Result<<Block as Block>::Header, Error>
fn expect_header(
&self,
id: BlockId<Block>
) -> Result<<Block as Block>::Header, Error>
Get block header. Returns UnknownBlock
error if block is not found.
sourceimpl<S, Block> HeaderMetadata<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
impl<S, Block> HeaderMetadata<Block> for Blockchain<S> where
Block: BlockT,
S: Storage<Block>,
type Error = ClientError
type Error = ClientError
Error used in case the header metadata is not found.
fn header_metadata(
&self,
hash: Block::Hash
) -> Result<CachedHeaderMetadata<Block>, Self::Error>
fn insert_header_metadata(
&self,
hash: Block::Hash,
metadata: CachedHeaderMetadata<Block>
)
fn remove_header_metadata(&self, hash: Block::Hash)
sourceimpl<S: Storage<Block>, Block: BlockT> ProvideCache<Block> for Blockchain<S>
impl<S: Storage<Block>, Block: BlockT> ProvideCache<Block> for Blockchain<S>
sourcefn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>>
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>>
Returns data cache reference, if it is enabled on this backend.
sourceimpl<S: Storage<Block>, Block: BlockT> ProvideChtRoots<Block> for Blockchain<S>
impl<S: Storage<Block>, Block: BlockT> ProvideChtRoots<Block> for Blockchain<S>
sourceimpl<S, Block: BlockT> RemoteBlockchain<Block> for Blockchain<S> where
S: Storage<Block>,
impl<S, Block: BlockT> RemoteBlockchain<Block> for Blockchain<S> where
S: Storage<Block>,
sourcefn header(
&self,
id: BlockId<Block>
) -> ClientResult<LocalOrRemote<Block::Header, RemoteHeaderRequest<Block::Header>>>
fn header(
&self,
id: BlockId<Block>
) -> ClientResult<LocalOrRemote<Block::Header, RemoteHeaderRequest<Block::Header>>>
Get block header.
Auto Trait Implementations
impl<S> RefUnwindSafe for Blockchain<S> where
S: RefUnwindSafe,
impl<S> Send for Blockchain<S> where
S: Send,
impl<S> Sync for Blockchain<S> where
S: Sync,
impl<S> Unpin for Blockchain<S> where
S: Unpin,
impl<S> UnwindSafe for Blockchain<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more