# [−] [src] Struct p2p::Context

    pub struct Context { /* fields omitted */ }

Network context.

## Methods

###

`impl Context`

[src]

####

`pub fn new( local_sync_node: LocalSyncNodeRef, pool_handle: CpuPool, remote: Remote, config: Config ) -> Result<Self, Box<Error>>`

[src]

Creates new context with reference to local sync node, thread pool and event loop.

####

`pub fn spawn<F>(&self, f: F) where F: Future + Send + 'static, F::Item: Send + 'static, F::Error: Send + 'static,`

[src]

Spawns a future using thread pool and schedules execution of it with event loop handle.

####

`pub fn execute_after<F>(&self, duration: Duration, f: F) where F: FnOnce() + 'static + Send,`

[src]

Schedules execution of function in future. Use wisely, it keeps used objects in memory until after it is resolved.

####
ⓘImportant traits for Vec<u8>

### Important traits for Vec<u8>

`impl Write for Vec<u8>`

`pub fn node_table_entries(&self) -> Vec<Node>`

[src]

Returns addresses of recently active nodes. Sorted and limited to 1000.

####

`pub fn update_node_table(&self, nodes: Vec<AddressEntry>)`

[src]

Updates node table.

####

`pub fn penalize_node(&self, addr: &SocketAddr)`

[src]

Penalize node.

####

`pub fn add_node(&self, addr: SocketAddr) -> Result<(), NodeTableError>`

[src]

Adds node to table.

####

`pub fn remove_node(&self, addr: SocketAddr) -> Result<(), NodeTableError>`

[src]

Removes node from table.

####

`pub fn autoconnect(context: Arc<Context>, handle: &Handle)`

[src]

Every 10 seconds check if we have reached maximum number of outbound connections. If not, connect to best peers.

####

`pub fn connect<T>(context: Arc<Context>, socket: SocketAddr) where T: SessionFactory,`

[src]

Connect to socket using given context.

####

`pub fn connect_normal(context: Arc<Context>, socket: SocketAddr)`

[src]

####
ⓘImportant traits for Box<R>

### Important traits for Box<R>

`impl<R> Read for Box<R> where
R: Read + ?Sized, impl<W> Write for Box<W> where
W: Write + ?Sized, impl<I> Iterator for Box<I> where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`pub fn accept_connection_future( context: Arc<Context>, stream: TcpStream, socket: SocketAddr, handle: &Handle, config: NetConfig ) -> Box<Future<Item = (), Error = ()> + Send>`

[src]

####

`pub fn accept_connection( context: Arc<Context>, stream: TcpStream, socket: SocketAddr, config: NetConfig )`

[src]

####

`pub fn listen( context: Arc<Context>, handle: &Handle, config: NetConfig ) -> Result<Box<Future<Item = (), Error = ()> + Send>, Error>`

[src]

Starts tcp server and listens for incomming connections.

####

`pub fn on_message( context: Arc<Context>, channel: Arc<Channel> ) -> IoFuture<MessageResult<()>>`

[src]

Called on incomming mesage.

####

`pub fn send_to_peer<T>( context: Arc<Context>, peer: PeerId, payload: &T, serialization_flags: u32 ) -> IoFuture<()> where T: Payload,`

[src]

Send message to a channel with given peer id.

####

`pub fn send_message_to_peer<T>( context: Arc<Context>, peer: PeerId, message: T ) -> IoFuture<()> where T: AsRef<[u8]> + Send + 'static,`

[src]

####

`pub fn send<T>( _context: Arc<Context>, channel: Arc<Channel>, message: T ) -> IoFuture<()> where T: AsRef<[u8]> + Send + 'static,`

[src]

Send message using given channel.

####

`pub fn close_channel(&self, id: PeerId)`

[src]

Close channel with given peer info.

####

`pub fn close_channel_with_error(&self, id: PeerId, error: &Error)`

[src]

Close channel with given peer info.

####

`pub fn create_sync_session( &self, start_height: i32, services: Services, outbound_connection: OutboundSyncConnectionRef ) -> InboundSyncConnectionRef`

[src]

####

`pub fn connections(&self) -> &Connections`

[src]

####
ⓘImportant traits for Vec<u8>

### Important traits for Vec<u8>

`impl Write for Vec<u8>`

`pub fn nodes(&self) -> Vec<Node>`

[src]

## Auto Trait Implementations

###

`impl Send for Context`

###

`impl Sync for Context`

## Blanket Implementations

###

`impl<T> From for T`

[src]

####

`fn from(t: T) -> T`

[src]

Performs the conversion.

###

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

[src]

####

`fn into(self) -> U`

[src]

Performs the conversion.

###

`impl<T, U> TryFrom for T where T: From<U>,`

[src]

#### `type Error = !`

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

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

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

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

[src]

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

`fn borrow(&self) -> &T`

[src]

Immutably borrows from an owned value. Read more

###

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

[src]

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

🔬 This is a nightly-only experimental API. (`try_from`)

The type returned in the event of a conversion error.

####

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

[src]

🔬 This is a nightly-only experimental API. (`try_from`)

Performs the conversion.

###

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

[src]

####
ⓘImportant traits for &'a mut R

### Important traits for &'a mut R

`impl<'a, R> Read for &'a mut R where
R: Read + ?Sized, impl<'a, W> Write for &'a mut W where
W: Write + ?Sized, impl<'a, I> Iterator for &'a mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;`

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

[src]

Mutably borrows from an owned value. Read more

###

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

[src]

####

`fn get_type_id(&self) -> TypeId`

[src]

🔬 This is a nightly-only experimental API. (`get_type_id`)

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

###

`impl<T> Erased for T`

# 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`)