# Trait ethcore::client::BlockChainClient [−] [src]

    pub trait BlockChainClient: Sync + Send {
        fn block_header(&self, id: BlockId) -> Option<Header>;
        fn block_number(&self, id: BlockId) -> Option<BlockNumber>;
        fn block_body(&self, id: BlockId) -> Option<Body>;
        fn block(&self, id: BlockId) -> Option<Block>;
        fn block_status(&self, id: BlockId) -> BlockStatus;
        fn block_total_difficulty(&self, id: BlockId) -> Option<U256>;
        fn nonce(&self, address: &Address, id: BlockId) -> Option<U256>;
        fn storage_root(&self, address: &Address, id: BlockId) -> Option<H256>;
        fn block_hash(&self, id: BlockId) -> Option<H256>;
        fn code(&self, address: &Address, id: BlockId) -> Option<Option<Bytes>>;
        fn balance(&self, address: &Address, id: BlockId) -> Option<U256>;
        fn storage_at(&self,
                  address: &Address,
                  position: &H256,
                  id: BlockId)
                  -> Option<H256>;
        fn list_accounts(&self,
                     id: BlockId,
                     after: Option<&Address>,
                     count: u64)
                     -> Option<Vec<Address>>;
        fn list_storage(&self,
                    id: BlockId,
                    account: &Address,
                    after: Option<&H256>,
                    count: u64)
                    -> Option<Vec<H256>>;
        fn transaction(&self, id: TransactionId) -> Option<LocalizedTransaction>;
        fn transaction_block(&self, id: TransactionId) -> Option<H256>;
        fn uncle(&self, id: UncleId) -> Option<Header>;
        fn transaction_receipt(&self, id: TransactionId) -> Option<LocalizedReceipt>;
        fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute>;
        fn find_uncles(&self, hash: &H256) -> Option<Vec<H256>>;
        fn state_data(&self, hash: &H256) -> Option<Bytes>;
        fn block_receipts(&self, hash: &H256) -> Option<Bytes>;
        fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError>;
        fn import_block_with_receipts(&self,
                                  block_bytes: Bytes,
                                  receipts_bytes: Bytes)
                                  -> Result<H256, BlockImportError>;
        fn queue_info(&self) -> BlockQueueInfo;
        fn clear_queue(&self);
        fn chain_info(&self) -> BlockChainInfo;
        fn additional_params(&self) -> BTreeMap<String, String>;
        fn best_block_header(&self) -> Header;
        fn blocks_with_bloom(&self,
                         bloom: &H2048,
                         from_block: BlockId,
                         to_block: BlockId)
                         -> Option<Vec<BlockNumber>>;
        fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry>;
        fn call(&self,
            t: &SignedTransaction,
            block: BlockId,
            analytics: CallAnalytics)
            -> Result<Executed, CallError>;
        fn estimate_gas(&self,
                    t: &SignedTransaction,
                    block: BlockId)
                    -> Result<U256, CallError>;
        fn replay(&self,
              t: TransactionId,
              analytics: CallAnalytics)
              -> Result<Executed, CallError>;
        fn filter_traces(&self, filter: TraceFilter) -> Option<Vec<LocalizedTrace>>;
        fn trace(&self, trace: TraceId) -> Option<LocalizedTrace>;
        fn transaction_traces(&self,
                          trace: TransactionId)
                          -> Option<Vec<LocalizedTrace>>;
        fn block_traces(&self, trace: BlockId) -> Option<Vec<LocalizedTrace>>;
        fn last_hashes(&self) -> LastHashes;
        fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: usize);
        fn queue_consensus_message(&self, message: Bytes);
        fn ready_transactions(&self) -> Vec<PendingTransaction>;
        fn signing_network_id(&self) -> Option<u64>;
        fn mode(&self) -> Mode;
        fn set_mode(&self, mode: Mode);
        fn disable(&self);
        fn block_extra_info(&self, id: BlockId) -> Option<BTreeMap<String, String>>;
        fn uncle_extra_info(&self, id: UncleId) -> Option<BTreeMap<String, String>>;
        fn pruning_info(&self) -> PruningInfo;
        fn call_contract(&self, address: Address, data: Bytes) -> Result<Bytes, String>;
        fn transact_contract(&self,
                         address: Address,
                         data: Bytes)
                         -> Result<TransactionImportResult, EthcoreError>;
        fn registrar_address(&self) -> Option<Address>;
        fn registry_address(&self, name: String) -> Option<Address>;

        fn keep_alive(&self) { ... }
        fn latest_nonce(&self, address: &Address) -> U256 { ... }
        fn latest_code(&self, address: &Address) -> Option<Bytes> { ... }
        fn latest_balance(&self, address: &Address) -> U256 { ... }
        fn latest_storage_at(&self, address: &Address, position: &H256) -> H256 { ... }
        fn gas_price_corpus(&self, sample_size: usize) -> Vec<U256> { ... }
        fn gas_price_median(&self, sample_size: usize) -> Option<U256> { ... }
        fn gas_price_histogram(&self,
                           sample_size: usize,
                           bucket_number: usize)
                           -> Option<Histogram> { ... }
    }

Blockchain database client. Owns and manages a blockchain and a block queue.

## Required Methods

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

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

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

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

May not return None if given BlockId::Latest. Returns None if and only if the block's root hash has been pruned from the DB.

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

May not return None if given BlockId::Latest. Returns None if and only if the block's root hash has been pruned from the DB.

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

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

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

### `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 best_block_header(&self) -> Header`

Get the best block header.

### `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 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,
t: TransactionId,
analytics: CallAnalytics)
-> Result<Executed, CallError>`

Replays a given transaction for inspection.

### `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,
trace: TransactionId)
-> Option<Vec<LocalizedTrace>>`

Returns traces created by transaction.

### `fn block_traces(&self, trace: 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 queue_consensus_message(&self, message: Bytes)`

Queue conensus engine message.

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

List all transactions that are allowed into the next block.

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

Get the preferred network ID to sign on

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

Get the mode.

### `fn set_mode(&self, mode: Mode)`

Set 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.

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

## Provided Methods

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

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

## Trait Implementations

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

#### `fn api_version() -> Version`

Current service api version Should be increased if any of the methods changes signature Read more

#### `fn protocol_version() -> Version`

Current ipc protocol version Should be increased only if signature of system methods changes Read more

#### `fn handshake(handshake: &Handshake) -> bool`

Default handshake requires exact versions match

## Implementors

- `impl BlockChainClient for TestBlockChainClient`
- `impl BlockChainClient for Client`

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