# [−] [src] Struct db::BlockChainDatabase

    pub struct BlockChainDatabase<T> where
        T: KeyValueDatabase,  { /* fields omitted */ }

## Methods

###

`impl BlockChainDatabase<CacheDatabase<AutoFlushingOverlayDatabase<DiskDatabase>>>`

[src]

####

`pub fn open_at_path<P>(path: P, total_cache: usize) -> Result<Self, Error> where P: AsRef<Path>,`

[src]

###

`impl BlockChainDatabase<MemoryDatabase>`

[src]

####

`pub fn init_test_chain(blocks: Vec<IndexedBlock>) -> Self`

[src]

###

`impl<T> BlockChainDatabase<CacheDatabase<AutoFlushingOverlayDatabase<T>>> where T: KeyValueDatabase,`

[src]

####

`pub fn open_with_cache(db: T) -> Self`

[src]

###

`impl<T> BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`pub fn open(db: T) -> Self`

[src]

####

`pub fn best_block(&self) -> BestBlock`

[src]

####

`pub fn fork( &self, side_chain: SideChainOrigin ) -> Result<ForkChainDatabase<T>, Error>`

[src]

####

`pub fn switch_to_fork(&self, fork: ForkChainDatabase<T>) -> Result<(), Error>`

[src]

####

`pub fn block_origin( &self, header: &IndexedBlockHeader ) -> Result<BlockOrigin, Error>`

[src]

####

`pub fn insert(&self, block: IndexedBlock) -> Result<(), Error>`

[src]

####

`pub fn canonize(&self, hash: &H256) -> Result<(), Error>`

[src]

Marks block as a new best block. Block must be already inserted into db, and it's parent must be current best block. Updates meta data.

####

`pub fn decanonize(&self) -> Result<H256, Error>`

[src]

## Trait Implementations

###

`impl<T> BlockHeaderProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn block_header_bytes(&self, block_ref: BlockRef) -> Option<Bytes>`

[src]

resolves header bytes by block reference (number/hash)

####

`fn block_header(&self, block_ref: BlockRef) -> Option<BlockHeader>`

[src]

resolves header bytes by block reference (number/hash)

###

`impl<T> BlockProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn block_number(&self, hash: &H256) -> Option<u32>`

[src]

resolves number by block hash

####

`fn block_hash(&self, number: u32) -> Option<H256>`

[src]

resolves hash by block number

####

`fn block(&self, block_ref: BlockRef) -> Option<Block>`

[src]

resolves deserialized block body by block reference (number/hash)

####

`fn contains_block(&self, block_ref: BlockRef) -> bool`

[src]

returns true if store contains given block

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

### Important traits for Vec<u8>

`impl Write for Vec<u8>`

`fn block_transaction_hashes(&self, block_ref: BlockRef) -> Vec<H256>`

[src]

resolves list of block transactions by block reference (number/hash)

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

### Important traits for Vec<u8>

`impl Write for Vec<u8>`

`fn block_transactions(&self, block_ref: BlockRef) -> Vec<Transaction>`

[src]

returns all transactions in the block by block reference (number/hash)

###

`impl<T> IndexedBlockProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn indexed_block_header( &self, block_ref: BlockRef ) -> Option<IndexedBlockHeader>`

[src]

####

`fn indexed_block(&self, block_ref: BlockRef) -> Option<IndexedBlock>`

[src]

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

### Important traits for Vec<u8>

`impl Write for Vec<u8>`

`fn indexed_block_transactions( &self, block_ref: BlockRef ) -> Vec<IndexedTransaction>`

[src]

###

`impl<T> TransactionMetaProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn transaction_meta(&self, hash: &H256) -> Option<TransactionMeta>`

[src]

Returns None if transactin with given hash does not exist Otherwise returns transaction meta object Read more

###

`impl<T> TransactionProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

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

[src]

Resolves transaction body bytes by transaction hash.

####

`fn transaction(&self, hash: &H256) -> Option<Transaction>`

[src]

Resolves serialized transaction info by transaction hash.

####

`fn contains_transaction(&self, hash: &H256) -> bool` |

Returns true if store contains given transaction.

###

`impl<T> TransactionOutputProvider for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn transaction_output( &self, prevout: &OutPoint, _transaction_index: usize ) -> Option<TransactionOutput>`

[src]

Returns transaction output.

####

`fn is_spent(&self, prevout: &OutPoint) -> bool`

[src]

Returns true if we know that output is double spent.

###

`impl<T> BlockChain for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn insert(&self, block: IndexedBlock) -> Result<(), Error>`

[src]

Inserts new block into blockchain

####

`fn rollback_best(&self) -> Result<H256, Error>`

[src]

Rollbacks single best block. Returns new best block hash

####

`fn canonize(&self, block_hash: &H256) -> Result<(), Error>`

[src]

Canonizes block with given hash

####

`fn decanonize(&self) -> Result<H256, Error>`

[src]

Decanonizes best block

####

`fn block_origin( &self, header: &IndexedBlockHeader ) -> Result<BlockOrigin, Error>`

[src]

Checks block origin

###

`impl<T> Forkable for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn fork<'a>( &'a self, side_chain: SideChainOrigin ) -> Result<Box<ForkChain + 'a>, Error>`

[src]

Forks current blockchain. Lifetime guarantees fork relationship with canon chain. Read more

####

`fn switch_to_fork<'a>(&self, fork: Box<ForkChain + 'a>) -> Result<(), Error>`

[src]

Switches blockchain to given fork. Lifetime guarantees that fork comes from this canon chain. Read more

###

`impl<T> CanonStore for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn as_store(&self) -> &Store`

[src]

###

`impl<T> Store for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn best_block(&self) -> BestBlock`

[src]

get best block

####

`fn best_header(&self) -> BlockHeader`

[src]

get best header

####

`fn difficulty(&self) -> f64`

[src]

get blockchain difficulty

###

`impl<T> ConfigStore for BlockChainDatabase<T> where T: KeyValueDatabase,`

[src]

####

`fn consensus_fork(&self) -> Result<Option<String>, Error>`

[src]

get consensus_fork this database is configured for

####

`fn set_consensus_fork(&self, consensus_fork: &str) -> Result<(), Error>`

[src]

set consensus_fork this database is configured for

## Auto Trait Implementations

###

`impl<T> Send for BlockChainDatabase<T>`

###

`impl<T> Sync for BlockChainDatabase<T>`

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

###

`impl<T> AsSubstore for T where T: BlockChain + IndexedBlockProvider + TransactionProvider + TransactionMetaProvider + TransactionOutputProvider,`

####

`fn as_block_provider(&self) -> &BlockProvider` |

####

`fn as_block_header_provider(&self) -> &BlockHeaderProvider` |

####

`fn as_transaction_provider(&self) -> &TransactionProvider` |

####

`fn as_transaction_output_provider(&self) -> &TransactionOutputProvider` |

####

`fn as_transaction_meta_provider(&self) -> &TransactionMetaProvider` |

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