     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47

    use std::{net, io};
    use std::time::Duration;
    use futures::{Future, Poll};
    use tokio_core::reactor::Handle;
    use tokio_core::net::TcpStream;
    use network::Magic;
    use message::{MessageResult};
    use io::{accept_handshake, AcceptHandshake, Deadline, deadline};
    use net::{Config, Connection};

    pub fn accept_connection(stream: TcpStream, handle: &Handle, config: &Config, address: net::SocketAddr) -> Deadline<AcceptConnection> {
    	let accept = AcceptConnection {
    		handshake: accept_handshake(stream, config.magic, config.version(&address), config.protocol_minimum),
    		magic: config.magic,
    		address: address,
    	};

    	deadline(Duration::new(5, 0), handle, accept).expect("Failed to create timeout")
    }

    pub struct AcceptConnection {
    	handshake: AcceptHandshake<TcpStream>,
    	magic: Magic,
    	address: net::SocketAddr,
    }

    impl Future for AcceptConnection {
    	type Item = MessageResult<Connection>;
    	type Error = io::Error;

    	fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
    		let (stream, result) = try_ready!(self.handshake.poll());
    		let result = match result {
    			Ok(result) => result,
    			Err(err) => return Ok(Err(err).into()),
    		};
    		let connection = Connection {
    			stream: stream.into(),
    			services: result.version.services(),
    			version: result.negotiated_version,
    			version_message: result.version,
    			magic: self.magic,
    			address: self.address,
    		};
    		Ok(Ok(connection).into())
    	}
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)