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,
capabilities: Capabilities,
config: P2PConfig,
adapter: Arc<dyn ChainAdapter>,
genesis: Hash,
stop_state: Arc<StopState>
) -> Result<Server, Error>
pub fn new( db_root: &str, capabilities: 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 Freeze for Server
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