# Struct ethcore::client::Client [−] [src]

    pub struct Client { /* fields omitted */ }

Blockchain database client backed by a persistent database. Owns and manages a blockchain and a block queue. Call `import_block()` to import a block asynchronously; `flush_queue()` flushes the queue.

## Methods

### `impl Client`
[src]

#### `fn new(config: ClientConfig,
spec: &Spec,
path: &Path,
miner: Arc<Miner>,
message_channel: IoChannel<ClientIoMessage>,
db_config: &DatabaseConfig)
-> Result<Arc<Client>, ClientError>`

Create a new client with given spec and DB path and custom verifier.

#### `fn add_notify(&self, target: Arc<ChainNotify>)`

Adds an actor to be notified on certain events

#### `fn engine(&self) -> &Engine`

Returns engine reference.

#### `fn registrar(&self) -> MutexGuard<Option<Registry>>`

Get the Registry object - useful for looking up names.

#### `fn on_mode_change<F>(&self, f: F) where F: 'static + FnMut(&Mode) + Send`

Register an action to be done if a mode change happens.

#### `fn flush_queue(&self)`

Flush the block import queue.

#### `fn import_verified_blocks(&self) -> usize`

This is triggered by a message coming from a block queue when the block is ready for insertion

#### `fn import_queued_transactions(&self,
transactions: &[Bytes],
peer_id: usize)
-> usize`

Import transactions from the IO queue

#### `fn miner(&self) -> Arc<Miner>`

Get shared miner reference.

#### `fn set_io_channel(&self, io_channel: IoChannel<ClientIoMessage>)`

Replace io channel. Useful for testing.

#### `fn state_at(&self, id: BlockId) -> Option<State>`

Attempt to get a copy of a specific block's final state.

This will not fail if given BlockId::Latest. Otherwise, this can fail (but may not) if the DB prunes state or the block is unknown.

#### `fn state_at_beginning(&self, id: BlockId) -> Option<State>`

Attempt to get a copy of a specific block's beginning state.

This will not fail if given BlockId::Latest. Otherwise, this can fail (but may not) if the DB prunes state.

#### `fn state(&self) -> State`

Get a copy of the best block's state.

#### `fn blockchain_cache_info(&self) -> BlockChainCacheSize`

Get info on the cache.

#### `fn report(&self) -> ClientReport`

Get the report.

#### `fn tick(&self)`

Tick the client.

#### `fn take_snapshot<W: SnapshotWriter + Send>(&self,
writer: W,
at: BlockId,
p: &Progress)
-> Result<(), EthcoreError>`

Take a snapshot at the given block. If the ID given is "latest", this will default to 1000 blocks behind.

#### `fn pruning_history(&self) -> u64`

Ask the client what the history parameter is.

## Trait Implementations

### `impl DatabaseRestore for Client`
[src]

#### `fn restore_db(&self, new_db: &str) -> Result<(), EthcoreError>`

Restart the client with a new backend

### `impl BlockChainClient for Client`
[src]

#### `fn call(&self,
t: &SignedTransaction,
block: BlockId,
analytics: CallAnalytics)
-> Result<Executed, CallError>`

Makes a non-persistent transaction call.

#### `fn estimate_gas(&self,
t: &SignedTransaction,
block: BlockId)
-> Result<U256, CallError>`

Estimates how much gas will be necessary for a call.

#### `fn replay(&self,
id: TransactionId,
analytics: CallAnalytics)
-> Result<Executed, CallError>`

Replays a given transaction for inspection.

#### `fn keep_alive(&self)`

Should be called by any external-facing interface when actively using the client. To minimise chatter, there's no need to call more than once every 30s. Read more

#### `fn mode(&self) -> IpcMode`

Get the mode.

#### `fn disable(&self)`

Disable the client from importing blocks. This cannot be undone in this session and indicates that a subsystem has reason to believe this executable incapable of syncing the chain. Read more

#### `fn set_mode(&self, new_mode: IpcMode)`

Set the mode.

#### `fn best_block_header(&self) -> Header`

Get the best block header.

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

Get raw block header data by block id.

#### `fn block_number(&self, id: BlockId) -> Option<BlockNumber>`

Look up the block number for the given block ID.

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

Get raw block body data by block id. Block body is an RLP list of two items: uncles and transactions. Read more

#### `fn block(&self, id: BlockId) -> Option<Block>`

Get raw block data by block header hash.

#### `fn block_status(&self, id: BlockId) -> BlockStatus`

Get block status by block header hash.

#### `fn block_total_difficulty(&self, id: BlockId) -> Option<U256>`

Get block total difficulty.

#### `fn nonce(&self, address: &Address, id: BlockId) -> Option<U256>`

Attempt to get address nonce at given block. May not fail on BlockId::Latest. Read more

#### `fn storage_root(&self, address: &Address, id: BlockId) -> Option<H256>`

Attempt to get address storage root at given block. May not fail on BlockId::Latest. Read more

#### `fn block_hash(&self, id: BlockId) -> Option<H256>`

Get block hash.

#### `fn code(&self, address: &Address, id: BlockId) -> Option<Option<Bytes>>`

Get address code at given block's state.

#### `fn balance(&self, address: &Address, id: BlockId) -> Option<U256>`

Get address balance at the given block's state. Read more

#### `fn storage_at(&self,
address: &Address,
position: &H256,
id: BlockId)
-> Option<H256>`

Get value of the storage at given position at the given block's state. Read more

#### `fn list_accounts(&self,
id: BlockId,
after: Option<&Address>,
count: u64)
-> Option<Vec<Address>>`

Get a list of all accounts in the block `id`, if fat DB is in operation, otherwise `None`. If `after` is set the list starts with the following item. Read more

#### `fn list_storage(&self,
id: BlockId,
account: &Address,
after: Option<&H256>,
count: u64)
-> Option<Vec<H256>>`

Get a list of all storage keys in the block `id`, if fat DB is in operation, otherwise `None`. If `after` is set the list starts with the following item. Read more

#### `fn transaction(&self, id: TransactionId) -> Option<LocalizedTransaction>`

Get transaction with given hash.

#### `fn transaction_block(&self, id: TransactionId) -> Option<H256>`

Get the hash of block that contains the transaction, if any.

#### `fn uncle(&self, id: UncleId) -> Option<Header>`

Get uncle with given id.

#### `fn transaction_receipt(&self, id: TransactionId) -> Option<LocalizedReceipt>`

Get transaction receipt with given hash.

#### `fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute>`

Get a tree route between `from` and `to`. See `BlockChain::tree_route`. Read more

#### `fn find_uncles(&self, hash: &H256) -> Option<Vec<H256>>`

Get all possible uncle hashes for a block.

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

Get latest state node

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

Get raw block receipts data by block header hash.

#### `fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError>`

Import a block into the blockchain.

#### `fn import_block_with_receipts(&self,
block_bytes: Bytes,
receipts_bytes: Bytes)
-> Result<H256, BlockImportError>`

Import a block with transaction receipts. Does no sealing and transaction validation.

#### `fn queue_info(&self) -> BlockQueueInfo`

Get block queue information.

#### `fn clear_queue(&self)`

Clear block queue and abort all import activity.

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

Get blockchain information.

#### `fn additional_params(&self) -> BTreeMap<String, String>`

Get the registrar address, if it exists.

#### `fn blocks_with_bloom(&self,
bloom: &H2048,
from_block: BlockId,
to_block: BlockId)
-> Option<Vec<BlockNumber>>`

Returns numbers of blocks containing given bloom.

#### `fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry>`

Returns logs matching given filter.

#### `fn filter_traces(&self, filter: TraceFilter) -> Option<Vec<LocalizedTrace>>`

Returns traces matching given filter.

#### `fn trace(&self, trace: TraceId) -> Option<LocalizedTrace>`

Returns trace with given id.

#### `fn transaction_traces(&self,
transaction: TransactionId)
-> Option<Vec<LocalizedTrace>>`

Returns traces created by transaction.

#### `fn block_traces(&self, block: BlockId) -> Option<Vec<LocalizedTrace>>`

Returns traces created by transaction from block.

#### `fn last_hashes(&self) -> LastHashes`

Get last hashes starting from best block.

#### `fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: usize)`

Queue transactions for importing.

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

List all transactions that are allowed into the next block.

#### `fn queue_consensus_message(&self, message: Bytes)`

Queue conensus engine message.

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

Get the preferred network ID to sign on

#### `fn block_extra_info(&self, id: BlockId) -> Option<BTreeMap<String, String>>`

Returns engine-related extra info for `BlockId`.

#### `fn uncle_extra_info(&self, id: UncleId) -> Option<BTreeMap<String, String>>`

Returns engine-related extra info for `UncleId`.

#### `fn pruning_info(&self) -> PruningInfo`

Returns information about pruning/data availability.

#### `fn call_contract(&self, address: Address, data: Bytes) -> Result<Bytes, String>`

Like `call`, but with various defaults. Designed to be used for calling contracts.

#### `fn transact_contract(&self,
address: Address,
data: Bytes)
-> Result<TransactionImportResult, EthcoreError>`

Import a transaction: used for misbehaviour reporting.

#### `fn registrar_address(&self) -> Option<Address>`

Get the address of the registry itself.

#### `fn registry_address(&self, name: String) -> Option<Address>`

Get the address of a particular blockchain service, if available.

#### `fn latest_nonce(&self, address: &Address) -> U256`

Get address nonce at the latest block's state.

#### `fn latest_code(&self, address: &Address) -> Option<Bytes>`

Get address code at the latest block's state.

#### `fn latest_balance(&self, address: &Address) -> U256`

Get address balance at the latest block's state.

#### `fn latest_storage_at(&self, address: &Address, position: &H256) -> H256`

Get value of the storage at given position at the latest block's state.

#### `fn gas_price_corpus(&self, sample_size: usize) -> Vec<U256>`

Sorted list of transaction gas prices from at least last sample_size blocks.

#### `fn gas_price_median(&self, sample_size: usize) -> Option<U256>`

Calculate median gas price from recent blocks if they have any transactions.

#### `fn gas_price_histogram(&self,
sample_size: usize,
bucket_number: usize)
-> Option<Histogram>`

Get the gas price distribution based on recent blocks if they have any transactions.

### `impl MiningBlockChainClient for Client`
[src]

#### `fn latest_schedule(&self) -> Schedule`

Returns latest schedule.

#### `fn prepare_open_block(&self,
author: Address,
gas_range_target: (U256, U256),
extra_data: Bytes)
-> OpenBlock`

Returns OpenBlock prepared for closing.

#### `fn vm_factory(&self) -> &EvmFactory`

Returns EvmFactory.

#### `fn broadcast_proposal_block(&self, block: SealedBlock)`

Broadcast a block proposal.

#### `fn import_sealed_block(&self, block: SealedBlock) -> ImportResult`

Import sealed block. Skips all verifications.

### `impl EngineClient for Client`
[src]

#### `fn update_sealing(&self)`

Make a new block and seal it.

#### `fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>)`

Submit a seal for a block in the mining queue.

#### `fn broadcast_consensus_message(&self, message: Bytes)`

Broadcast a consensus message to the network.

### `impl MayPanic for Client`
[src]

#### `fn on_panic<F>(&self, closure: F) where F: OnPanicListener`

`closure` will be invoked whenever panic in thread is caught

### `impl ProvingBlockChainClient for Client`
[src]

#### `fn prove_storage(&self,
key1: H256,
key2: H256,
from_level: u32,
id: BlockId)
-> Vec<Bytes>`

Prove account storage at a specific block id. Read more

#### `fn prove_account(&self, key1: H256, from_level: u32, id: BlockId) -> Vec<Bytes>`

Prove account existence at a specific block id. The key is the keccak hash of the account's address. Returns a vector of raw trie nodes (in order from the root) proving the query. Nodes after `from_level` may be omitted. An empty vector indicates unservable query. Read more

#### `fn code_by_hash(&self, account_key: H256, id: BlockId) -> Bytes`

Get code by address hash.

### `impl Drop for Client`
[src]

#### `fn drop(&mut self)`

A method called when the value goes out of scope. 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`)