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

source

pub fn new( reserved_peers_updates: Sender<usize>, config: Config, codec: PostcardCodec, ) -> Self

source

pub async fn start(&mut self) -> Result<()>

source

pub fn get_peers_ids_iter(&self) -> impl Iterator<Item = &PeerId>

source

pub fn publish_message( &mut self, message: GossipsubBroadcastRequest, ) -> Result<MessageId, PublishError>

source

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

source

pub fn send_response_msg( &mut self, request_id: InboundRequestId, message: ResponseMessage, ) -> Result<(), ResponseSendError>

Sends ResponseMessage to a peer that requested the data

source

pub fn update_block_height(&mut self, block_height: BlockHeight)

source

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

source

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

source

pub async fn next_event(&mut self) -> Option<FuelP2PEvent>

Handles P2P Events. Returns only events that are of interest to the Network Orchestrator.

source

pub fn peer_manager(&self) -> &PeerManager

Trait Implementations§

source§

impl TaskP2PService for FuelP2PService

source§

fn get_all_peer_info(&self) -> Vec<(&PeerId, &PeerInfo)>

source§

fn get_peer_id_with_height(&self, height: &BlockHeight) -> Option<PeerId>

source§

fn next_event(&mut self) -> BoxFuture<'_, Option<FuelP2PEvent>>

source§

fn publish_message(&mut self, message: GossipsubBroadcastRequest) -> Result<()>

source§

fn send_request_msg( &mut self, peer_id: Option<PeerId>, request_msg: RequestMessage, on_response: ResponseSender, ) -> Result<()>

source§

fn send_response_msg( &mut self, request_id: InboundRequestId, message: ResponseMessage, ) -> Result<()>

source§

fn report_message( &mut self, message: GossipsubMessageInfo, acceptance: GossipsubMessageAcceptance, ) -> Result<()>

source§

fn report_peer( &mut self, peer_id: PeerId, score: AppScore, reporting_service: &str, ) -> Result<()>

source§

fn update_block_height(&mut self, height: BlockHeight) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

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>,

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>>
where M: Mappable, P: AsRef<[u8]>, Self: IterableTable<M>,

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>,

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>>
where M: Mappable, P: AsRef<[u8]>, Self: IterableTable<M>,

Returns an iterator over the all entries in the table with a prefix after a specific start key.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> StorageAsMut for T

source§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>
where Type: Mappable,

source§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>
where Type: Mappable,

source§

impl<T> StorageAsRef for T

source§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>
where Type: Mappable,

source§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>
where Type: Mappable,

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more