Struct stack_epic_p2p::Server
source · pub struct Server {
pub config: P2PConfig,
pub peers: Arc<Peers>,
/* private fields */
}Expand description
P2P server implementation, handling bootstrapping to find and connect to peers, receiving connections from other peers and keep track of all of them.
Fields§
§config: P2PConfig§peers: Arc<Peers>Implementations§
source§impl Server
impl Server
sourcepub fn new(
db_root: &str,
capab: Capabilities,
config: P2PConfig,
adapter: Arc<dyn ChainAdapter>,
genesis: Hash,
stop_state: Arc<StopState>
) -> Result<Server, Error>
pub fn new( db_root: &str, capab: Capabilities, config: P2PConfig, adapter: Arc<dyn ChainAdapter>, genesis: Hash, stop_state: Arc<StopState> ) -> Result<Server, Error>
Creates a new idle p2p server with no peers
sourcepub fn listen(&self) -> Result<(), Error>
pub fn listen(&self) -> Result<(), Error>
Starts a new TCP server and listen to incoming connections. This is a blocking call until the TCP server stops.
sourcepub fn connect(&self, addr: PeerAddr) -> Result<Arc<Peer>, Error>
pub fn connect(&self, addr: PeerAddr) -> Result<Arc<Peer>, Error>
Asks the server to connect to a new peer. Directly returns the peer if we’re already connected to the provided address.
pub fn stop(&self)
Auto Trait Implementations§
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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
§impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
§fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
Given
ptr, which was obtained from a prior call to Self::borrow(),
return a value with the same nominal lifetime which is guaranteed to
survive mutations to Self. Read more