# Trait ethcore_light::provider::Provider [−] [src]

    pub trait Provider: Send + Sync {
        fn chain_info(&self) -> BlockChainInfo;
        fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64>;
        fn earliest_state(&self) -> Option<u64>;
        fn block_header(&self, id: BlockId) -> Option<Header>;
        fn block_body(&self, id: BlockId) -> Option<Body>;
        fn block_receipts(&self, hash: &H256) -> Option<Bytes>;
        fn state_proof(&self, req: StateProof) -> Vec<Bytes>;
        fn contract_code(&self, req: ContractCode) -> Bytes;
        fn header_proof(&self, req: HeaderProof) -> Option<(Header, Vec<Bytes>)>;
        fn ready_transactions(&self) -> Vec<PendingTransaction>;

        fn block_headers(&self, req: Headers) -> Vec<Header> { ... }
        fn block_bodies(&self, req: Bodies) -> Vec<Option<Body>> { ... }
        fn receipts(&self, req: Receipts) -> Vec<Bytes> { ... }
        fn proofs(&self, req: StateProofs) -> Vec<Bytes> { ... }
        fn contract_codes(&self, req: ContractCodes) -> Vec<Bytes> { ... }
        fn header_proofs(&self, req: HeaderProofs) -> Vec<Bytes> { ... }
    }

Defines the operations that a provider for `LES` must fulfill.

These are defined at 1, but may be subject to change. Requests which can't be fulfilled should return either an empty RLP list or empty vector where appropriate.

## Required Methods

### `fn chain_info(&self) -> BlockChainInfo`

Provide current blockchain info.

### `fn reorg_depth(&self, a: &H256, b: &H256) -> Option<u64>`

Find the depth of a common ancestor between two blocks. If either block is unknown or an ancestor can't be found then return `None`.

### `fn earliest_state(&self) -> Option<u64>`

Earliest block where state queries are available. If `None`, no state queries are servable.

### `fn block_header(&self, id: BlockId) -> Option<Header>`

Get a block header by id.

### `fn block_body(&self, id: BlockId) -> Option<Body>`

Get a block body by id.

### `fn block_receipts(&self, hash: &H256) -> Option<Bytes>`

Get a block's receipts as an RLP-encoded list by block hash.

### `fn state_proof(&self, req: StateProof) -> Vec<Bytes>`

Get a state proof from a request. Each proof should be a vector of rlp-encoded trie nodes, in ascending order by distance from the root.

### `fn contract_code(&self, req: ContractCode) -> Bytes`

Get contract code by request. Either the raw bytecode or empty.

### `fn header_proof(&self, req: HeaderProof) -> Option<(Header, Vec<Bytes>)>`

Provide a header proof from a given Canonical Hash Trie as well as the corresponding header. The first element is the block header and the second is a merkle proof of the CHT.

### `fn ready_transactions(&self) -> Vec<PendingTransaction>`

Provide pending transactions.

## Provided Methods

### `fn block_headers(&self, req: Headers) -> Vec<Header>`

Provide a list of headers starting at the requested block, possibly in reverse and skipping `skip` at a time.

The returned vector may have any length in the range [0, `max`], but the results within must adhere to the `skip` and `reverse` parameters.

### `fn block_bodies(&self, req: Bodies) -> Vec<Option<Body>>`

Provide as many as possible of the requested blocks (minus the headers) encoded in RLP format.

### `fn receipts(&self, req: Receipts) -> Vec<Bytes>`

Provide the receipts as many as possible of the requested blocks. Returns a vector of RLP-encoded lists of receipts.

### `fn proofs(&self, req: StateProofs) -> Vec<Bytes>`

Provide a set of merkle proofs, as requested. Each request is a block hash and request parameters.

Returns a vector of RLP-encoded lists satisfying the requests.

### `fn contract_codes(&self, req: ContractCodes) -> Vec<Bytes>`

Provide contract code for the specified (block_hash, account_hash) pairs. Each item in the resulting vector is either the raw bytecode or empty.

### `fn header_proofs(&self, req: HeaderProofs) -> Vec<Bytes>`

Provide header proofs from the Canonical Hash Tries as well as the headers they correspond to -- each element in the returned vector is a 2-tuple. The first element is a block header and the second a merkle proof of the header in a requested CHT.

## Implementors

- `impl Provider for Client`
- `impl<T: ProvingBlockChainClient + ?Sized> Provider for T`

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