pub struct HandshakerBuilder<N: NetworkZone, AdrBook = DummyAddressBook, CSync = DummyCoreSyncSvc, ProtoHdlrMkr = MapErr<Shared<DummyProtocolRequestHandler>, fn(_: Infallible) -> BoxError>, BrdcstStrmMkr = fn(_: InternalPeerID<<N as NetworkZone>::Addr>) -> Pending<BroadcastMessage>> { /* private fields */ }
Expand description
A HandShaker
Service
builder.
This builder applies default values to make usage easier, behaviour and drawbacks of the defaults are documented
on the with_*
method to change it, for example HandshakerBuilder::with_protocol_request_handler_maker
.
If you want to use any network other than Mainnet
you will need to change the core sync service with HandshakerBuilder::with_core_sync_svc
,
see that method for details.
Implementations§
Source§impl<N: NetworkZone> HandshakerBuilder<N>
impl<N: NetworkZone> HandshakerBuilder<N>
Sourcepub fn new(our_basic_node_data: BasicNodeData) -> Self
pub fn new(our_basic_node_data: BasicNodeData) -> Self
Creates a new builder with our node’s basic node data.
Source§impl<N: NetworkZone, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>
impl<N: NetworkZone, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>
Sourcepub fn with_address_book<NAdrBook>(
self,
new_address_book: NAdrBook,
) -> HandshakerBuilder<N, NAdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>where
NAdrBook: AddressBook<N> + Clone,
pub fn with_address_book<NAdrBook>(
self,
new_address_book: NAdrBook,
) -> HandshakerBuilder<N, NAdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>where
NAdrBook: AddressBook<N> + Clone,
Changes the address book to the provided one.
§Default Address Book
The default address book is used if this function is not called.
The default address book’s only drawback is that it does not keep track of peers and therefore bans.
Sourcepub fn with_core_sync_svc<NCSync>(
self,
new_core_sync_svc: NCSync,
) -> HandshakerBuilder<N, AdrBook, NCSync, ProtoHdlr, BrdcstStrmMkr>where
NCSync: CoreSyncSvc + Clone,
pub fn with_core_sync_svc<NCSync>(
self,
new_core_sync_svc: NCSync,
) -> HandshakerBuilder<N, AdrBook, NCSync, ProtoHdlr, BrdcstStrmMkr>where
NCSync: CoreSyncSvc + Clone,
Changes the core sync service to the provided one.
The core sync service should keep track of our nodes core sync data.
§Default Core Sync Service
The default core sync service is used if this method is not called.
The default core sync service will just use the mainnet genesis block, to use other network’s
genesis see DummyCoreSyncSvc::static_stagenet_genesis
and DummyCoreSyncSvc::static_testnet_genesis
.
The drawbacks to keeping this the default is that it will always return the mainnet genesis as our nodes
sync info, which means peers won’t know our actual chain height, this may or may not be a problem for
different use cases.
Sourcepub fn with_protocol_request_handler_maker<NProtoHdlrMkr>(
self,
new_protocol_request_svc_maker: NProtoHdlrMkr,
) -> HandshakerBuilder<N, AdrBook, CSync, NProtoHdlrMkr, BrdcstStrmMkr>where
NProtoHdlrMkr: ProtocolRequestHandlerMaker<N> + Clone,
pub fn with_protocol_request_handler_maker<NProtoHdlrMkr>(
self,
new_protocol_request_svc_maker: NProtoHdlrMkr,
) -> HandshakerBuilder<N, AdrBook, CSync, NProtoHdlrMkr, BrdcstStrmMkr>where
NProtoHdlrMkr: ProtocolRequestHandlerMaker<N> + Clone,
Changes the protocol request handler maker, which creates the service that handles ProtocolRequest
s
to our node.
§Default Protocol Request Handler
The default service maker will create services that will not respond to any protocol requests, this should not be an issue as long as peers do not think we are ahead of them, if they do they will send requests for our blocks, and we won’t respond which will cause them to disconnect.
Sourcepub fn with_broadcast_stream_maker<NBrdcstStrmMkr, BrdcstStrm>(
self,
new_broadcast_stream_maker: NBrdcstStrmMkr,
) -> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlr, NBrdcstStrmMkr>where
BrdcstStrm: Stream<Item = BroadcastMessage> + Send + 'static,
NBrdcstStrmMkr: Fn(InternalPeerID<N::Addr>) -> BrdcstStrm + Clone + Send + 'static,
pub fn with_broadcast_stream_maker<NBrdcstStrmMkr, BrdcstStrm>(
self,
new_broadcast_stream_maker: NBrdcstStrmMkr,
) -> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlr, NBrdcstStrmMkr>where
BrdcstStrm: Stream<Item = BroadcastMessage> + Send + 'static,
NBrdcstStrmMkr: Fn(InternalPeerID<N::Addr>) -> BrdcstStrm + Clone + Send + 'static,
Changes the broadcast stream maker, which is used to create streams that yield messages to broadcast.
§Default Broadcast Stream Maker
The default broadcast stream maker just returns stream::Pending
, i.e. the returned stream will not
produce any messages to broadcast, this is not a problem if your use case does not require broadcasting
messages.
Sourcepub fn with_connection_parent_span(self, connection_parent_span: Span) -> Self
pub fn with_connection_parent_span(self, connection_parent_span: Span) -> Self
Changes the parent Span
of the connection task to the one provided.
§Default Connection Parent Span
The default connection span will be Span::none
.
Sourcepub fn build(self) -> HandShaker<N, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>
pub fn build(self) -> HandShaker<N, AdrBook, CSync, ProtoHdlr, BrdcstStrmMkr>
Builds the HandShaker
.
Trait Implementations§
Source§impl<N: Clone + NetworkZone, AdrBook: Clone, CSync: Clone, ProtoHdlrMkr: Clone, BrdcstStrmMkr: Clone> Clone for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N: Clone + NetworkZone, AdrBook: Clone, CSync: Clone, ProtoHdlrMkr: Clone, BrdcstStrmMkr: Clone> Clone for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
Source§fn clone(
&self,
) -> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
fn clone( &self, ) -> HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr> Freeze for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N, AdrBook = DummyAddressBook, CSync = DummyCoreSyncSvc, ProtoHdlrMkr = MapErr<Shared<DummyProtocolRequestHandler>, fn(_: Infallible) -> Box<dyn Error + Send + Sync>>, BrdcstStrmMkr = fn(_: InternalPeerID<<N as NetworkZone>::Addr>) -> Pending<BroadcastMessage>> !RefUnwindSafe for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr> Send for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr> Sync for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr> Unpin for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
impl<N, AdrBook = DummyAddressBook, CSync = DummyCoreSyncSvc, ProtoHdlrMkr = MapErr<Shared<DummyProtocolRequestHandler>, fn(_: Infallible) -> Box<dyn Error + Send + Sync>>, BrdcstStrmMkr = fn(_: InternalPeerID<<N as NetworkZone>::Addr>) -> Pending<BroadcastMessage>> !UnwindSafe for HandshakerBuilder<N, AdrBook, CSync, ProtoHdlrMkr, BrdcstStrmMkr>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.