Struct sc_network_test::Peer
source · pub struct Peer<D, BlockImport> {
pub data: D,
/* private fields */
}
Fields§
§data: D
Implementations§
source§impl<D, B> Peer<D, B>
impl<D, B> Peer<D, B>
sourcepub fn is_major_syncing(&self) -> bool
pub fn is_major_syncing(&self) -> bool
Returns true if we’re major syncing.
pub fn select_chain(&self) -> Option<LongestChain<Backend, Block>>
sourcepub async fn num_downloaded_blocks(&self) -> usize
pub async fn num_downloaded_blocks(&self) -> usize
Returns the number of downloaded blocks.
sourcepub fn is_offline(&self) -> bool
pub fn is_offline(&self) -> bool
Returns true if we have no peer.
sourcepub fn request_justification(
&self,
hash: &<Block as BlockT>::Hash,
number: NumberFor<Block>,
)
pub fn request_justification( &self, hash: &<Block as BlockT>::Hash, number: NumberFor<Block>, )
Request a justification for the given block.
sourcepub fn announce_block(
&self,
hash: <Block as BlockT>::Hash,
data: Option<Vec<u8>>,
)
pub fn announce_block( &self, hash: <Block as BlockT>::Hash, data: Option<Vec<u8>>, )
Announces an important block on the network.
sourcepub fn set_sync_fork_request(
&self,
peers: Vec<PeerId>,
hash: <Block as BlockT>::Hash,
number: NumberFor<Block>,
)
pub fn set_sync_fork_request( &self, peers: Vec<PeerId>, hash: <Block as BlockT>::Hash, number: NumberFor<Block>, )
Request explicit fork sync.
sourcepub fn generate_blocks<F>(
&mut self,
count: usize,
origin: BlockOrigin,
edit_block: F,
) -> Vec<H256>
pub fn generate_blocks<F>( &mut self, count: usize, origin: BlockOrigin, edit_block: F, ) -> Vec<H256>
Add blocks to the peer – edit the block before adding
sourcepub fn generate_blocks_with_fork_choice<F>(
&mut self,
count: usize,
origin: BlockOrigin,
edit_block: F,
fork_choice: ForkChoiceStrategy,
) -> Vec<H256>
pub fn generate_blocks_with_fork_choice<F>( &mut self, count: usize, origin: BlockOrigin, edit_block: F, fork_choice: ForkChoiceStrategy, ) -> Vec<H256>
Add blocks to the peer – edit the block before adding and use custom fork choice rule.
sourcepub fn generate_blocks_at<F>(
&mut self,
at: BlockId<Block>,
count: usize,
origin: BlockOrigin,
edit_block: F,
headers_only: bool,
inform_sync_about_new_best_block: bool,
announce_block: bool,
fork_choice: ForkChoiceStrategy,
) -> Vec<H256>
pub fn generate_blocks_at<F>( &mut self, at: BlockId<Block>, count: usize, origin: BlockOrigin, edit_block: F, headers_only: bool, inform_sync_about_new_best_block: bool, announce_block: bool, fork_choice: ForkChoiceStrategy, ) -> Vec<H256>
Add blocks to the peer – edit the block before adding. The chain will start at the given block iD.
sourcepub fn push_blocks(&mut self, count: usize, with_tx: bool) -> Vec<H256>
pub fn push_blocks(&mut self, count: usize, with_tx: bool) -> Vec<H256>
Push blocks to the peer (simplified: with or without a TX)
sourcepub fn push_headers(&mut self, count: usize) -> Vec<H256>
pub fn push_headers(&mut self, count: usize) -> Vec<H256>
Push blocks to the peer (simplified: with or without a TX)
sourcepub fn push_blocks_at(
&mut self,
at: BlockId<Block>,
count: usize,
with_tx: bool,
) -> Vec<H256>
pub fn push_blocks_at( &mut self, at: BlockId<Block>, count: usize, with_tx: bool, ) -> Vec<H256>
Push blocks to the peer (simplified: with or without a TX) starting from given hash.
sourcepub fn push_blocks_at_without_informing_sync(
&mut self,
at: BlockId<Block>,
count: usize,
with_tx: bool,
announce_block: bool,
) -> Vec<H256>
pub fn push_blocks_at_without_informing_sync( &mut self, at: BlockId<Block>, count: usize, with_tx: bool, announce_block: bool, ) -> Vec<H256>
Push blocks to the peer (simplified: with or without a TX) starting from given hash without informing the sync protocol about the new best block.
sourcepub fn push_blocks_at_without_announcing(
&mut self,
at: BlockId<Block>,
count: usize,
with_tx: bool,
) -> Vec<H256>
pub fn push_blocks_at_without_announcing( &mut self, at: BlockId<Block>, count: usize, with_tx: bool, ) -> Vec<H256>
Push blocks to the peer (simplified: with or without a TX) starting from given hash without announcing the block.
sourcepub fn client(&self) -> &PeersClient
pub fn client(&self) -> &PeersClient
Get a reference to the client.
sourcepub fn network_service(
&self,
) -> &Arc<NetworkService<Block, <Block as BlockT>::Hash>>
pub fn network_service( &self, ) -> &Arc<NetworkService<Block, <Block as BlockT>::Hash>>
Get a reference to the network service.
sourcepub fn sync_service(&self) -> &Arc<SyncingService<Block>>
pub fn sync_service(&self) -> &Arc<SyncingService<Block>>
Get SyncingService
.
sourcepub fn take_notification_service(
&mut self,
protocol: &ProtocolName,
) -> Option<Box<dyn NotificationService>>
pub fn take_notification_service( &mut self, protocol: &ProtocolName, ) -> Option<Box<dyn NotificationService>>
Take notification handle for enabled protocol.
sourcepub fn network(&self) -> &NetworkWorker<Block, <Block as BlockT>::Hash>
pub fn network(&self) -> &NetworkWorker<Block, <Block as BlockT>::Hash>
Get a reference to the network worker.
sourcepub fn blockchain_canon_equals(&self, other: &Self) -> bool
pub fn blockchain_canon_equals(&self, other: &Self) -> bool
Test helper to compare the blockchain state of multiple (networked) clients.
sourcepub fn blocks_count(&self) -> u64
pub fn blocks_count(&self) -> u64
Count the total number of imported blocks.
sourcepub fn failed_verifications(&self) -> HashMap<<Block as BlockT>::Hash, String>
pub fn failed_verifications(&self) -> HashMap<<Block as BlockT>::Hash, String>
Return a collection of block hashes that failed verification
pub fn has_block(&self, hash: H256) -> bool
pub fn has_body(&self, hash: H256) -> bool
Auto Trait Implementations§
impl<D, BlockImport> !Freeze for Peer<D, BlockImport>
impl<D, BlockImport> !RefUnwindSafe for Peer<D, BlockImport>
impl<D, BlockImport> Send for Peer<D, BlockImport>
impl<D, BlockImport> !Sync for Peer<D, BlockImport>
impl<D, BlockImport> Unpin for Peer<D, BlockImport>
impl<D, BlockImport> !UnwindSafe for Peer<D, BlockImport>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
source§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.