Struct fuel_core_p2p::p2p_service::FuelP2PService
source · pub struct FuelP2PService {
pub local_peer_id: PeerId,
/* private fields */
}
Expand description
Listens to the events on the p2p network And forwards them to the Orchestrator
Fields§
§local_peer_id: PeerId
Store the local peer id
Implementations§
source§impl FuelP2PService
impl FuelP2PService
pub fn new( reserved_peers_updates: Sender<usize>, config: Config, codec: PostcardCodec, ) -> Self
pub async fn start(&mut self) -> Result<()>
pub fn get_peers_ids_iter(&self) -> impl Iterator<Item = &PeerId>
pub fn publish_message( &mut self, message: GossipsubBroadcastRequest, ) -> Result<MessageId, PublishError>
sourcepub fn send_request_msg(
&mut self,
peer_id: Option<PeerId>,
message_request: RequestMessage,
on_response: ResponseSender,
) -> Result<OutboundRequestId, RequestError>
pub fn send_request_msg( &mut self, peer_id: Option<PeerId>, message_request: RequestMessage, on_response: ResponseSender, ) -> Result<OutboundRequestId, RequestError>
Sends RequestMessage to a peer If the peer is not defined it will pick one at random Only returns error if no peers are connected
sourcepub fn send_response_msg(
&mut self,
request_id: InboundRequestId,
message: ResponseMessage,
) -> Result<(), ResponseSendError>
pub fn send_response_msg( &mut self, request_id: InboundRequestId, message: ResponseMessage, ) -> Result<(), ResponseSendError>
Sends ResponseMessage to a peer that requested the data
pub fn update_block_height(&mut self, block_height: BlockHeight)
sourcepub fn report_message_validation_result(
&mut self,
msg_id: &MessageId,
propagation_source: PeerId,
acceptance: MessageAcceptance,
)
pub fn report_message_validation_result( &mut self, msg_id: &MessageId, propagation_source: PeerId, acceptance: MessageAcceptance, )
The report is forwarded to gossipsub behaviour If acceptance is “Rejected” the gossipsub peer score is calculated And if it’s below allowed threshold the peer is banned
sourcepub fn report_peer(
&mut self,
peer_id: PeerId,
app_score: AppScore,
reporting_service: &str,
)
pub fn report_peer( &mut self, peer_id: PeerId, app_score: AppScore, reporting_service: &str, )
Report application score If application peer score is below allowed threshold the peer is banned
sourcepub async fn next_event(&mut self) -> Option<FuelP2PEvent>
pub async fn next_event(&mut self) -> Option<FuelP2PEvent>
Handles P2P Events. Returns only events that are of interest to the Network Orchestrator.
pub fn peer_manager(&self) -> &PeerManager
Trait Implementations§
source§impl TaskP2PService for FuelP2PService
impl TaskP2PService for FuelP2PService
fn get_all_peer_info(&self) -> Vec<(&PeerId, &PeerInfo)>
fn get_peer_id_with_height(&self, height: &BlockHeight) -> Option<PeerId>
fn next_event(&mut self) -> BoxFuture<'_, Option<FuelP2PEvent>>
fn publish_message(&mut self, message: GossipsubBroadcastRequest) -> Result<()>
fn send_request_msg( &mut self, peer_id: Option<PeerId>, request_msg: RequestMessage, on_response: ResponseSender, ) -> Result<()>
fn send_response_msg( &mut self, request_id: InboundRequestId, message: ResponseMessage, ) -> Result<()>
fn report_message( &mut self, message: GossipsubMessageInfo, acceptance: GossipsubMessageAcceptance, ) -> Result<()>
fn report_peer( &mut self, peer_id: PeerId, score: AppScore, reporting_service: &str, ) -> Result<()>
fn update_block_height(&mut self, height: BlockHeight) -> Result<()>
Auto Trait Implementations§
impl !Freeze for FuelP2PService
impl !RefUnwindSafe for FuelP2PService
impl Send for FuelP2PService
impl !Sync for FuelP2PService
impl Unpin for FuelP2PService
impl !UnwindSafe for FuelP2PService
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moresource§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table.
source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with the specified prefix.
source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Returns an iterator over the all entries in the table after a specific start key.
source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Returns an iterator over the all entries in the table with a prefix after a specific start key.