# Struct ethcore_light::on_demand::OnDemand [−] [src]

    pub struct OnDemand { /* fields omitted */ }

On demand request service. See module docs for more details. Accumulates info about all peers' capabilities and dispatches requests to them accordingly.

## Methods

### `impl OnDemand`
[src]

#### `fn header_by_number(&self,
ctx: &BasicContext,
req: HeaderByNumber)
-> Response<Header>`

Request a header by block number and CHT root hash.

#### `fn header_by_hash(&self,
ctx: &BasicContext,
req: HeaderByHash)
-> Response<Header>`

Request a header by hash. This is less accurate than by-number because we don't know where in the chain this header lies, and therefore can't find a peer who is supposed to have it as easily.

#### `fn block(&self, ctx: &BasicContext, req: Body) -> Response<Block>`

Request a block, given its header. Block bodies are requestable by hash only, and the header is required anyway to verify and complete the block body -- this just doesn't obscure the network query.

#### `fn block_receipts(&self,
ctx: &BasicContext,
req: BlockReceipts)
-> Response<Vec<Receipt>>`

Request the receipts for a block. The header serves two purposes: provide the block hash to fetch receipts for, and for verification of the receipts root.

#### `fn account(&self, ctx: &BasicContext, req: Account) -> Response<BasicAccount>`

Request an account by address and block header -- which gives a hash to query and a state root to verify against.

## Trait Implementations

### `impl Default for OnDemand`
[src]

#### `fn default() -> Self`

Returns the "default value" for a type. Read more

### `impl Handler for OnDemand`
[src]

#### `fn on_connect(&self,
ctx: &EventContext,
status: &Status,
capabilities: &Capabilities)`

Called when a peer connects.

#### `fn on_disconnect(&self, ctx: &EventContext, unfulfilled: &[ReqId])`

Called when a peer disconnects, with a list of unfulfilled request IDs as of yet. Read more

#### `fn on_announcement(&self, ctx: &EventContext, announcement: &Announcement)`

Called when a peer makes an announcement.

#### `fn on_header_proofs(&self,
ctx: &EventContext,
req_id: ReqId,
proofs: &[(Bytes, Vec<Bytes>)])`

Called when a peer responds with header proofs. Each proof should be a block header coupled with a series of trie nodes is ascending order by distance from the root. Read more

#### `fn on_block_headers(&self, ctx: &EventContext, req_id: ReqId, headers: &[Bytes])`

Called when a peer responds with block headers.

#### `fn on_block_bodies(&self, ctx: &EventContext, req_id: ReqId, bodies: &[Bytes])`

Called when a peer responds with block bodies.

#### `fn on_receipts(&self,
ctx: &EventContext,
req_id: ReqId,
receipts: &[Vec<Receipt>])`

Called when a peer responds with block receipts.

#### `fn on_state_proofs(&self,
ctx: &EventContext,
req_id: ReqId,
proofs: &[Vec<Bytes>])`

Called when a peer responds with state proofs. Each proof should be a series of trie nodes in ascending order by distance from the root. Read more

#### `fn on_transactions(&self, _ctx: &EventContext, _relay: &[UnverifiedTransaction])`

Called when a peer requests relay of some transactions.

#### `fn on_code(&self, _ctx: &EventContext, _req_id: ReqId, _codes: &[Bytes])`

Called when a peer responds with contract code.

#### `fn tick(&self, _ctx: &BasicContext)`

Called to "tick" the handler periodically.

#### `fn on_abort(&self)`

Called on abort. This signals to handlers that they should clean up and ignore peers. Read more

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand 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`)