pub struct Blockchain { /* private fields */ }
Expand description
The blockchain
Implementations§
Source§impl Blockchain
impl Blockchain
Sourcepub fn new(network: Network) -> Blockchain
pub fn new(network: Network) -> Blockchain
Constructs a new blockchain
Sourcepub fn get_block(&self, hash: Sha256dHash) -> Option<&BlockchainNode>
pub fn get_block(&self, hash: Sha256dHash) -> Option<&BlockchainNode>
Looks up a block in the chain and returns the BlockchainNode containing it
Sourcepub fn add_txdata(&mut self, block: Block) -> Result<(), BlockchainError>
pub fn add_txdata(&mut self, block: Block) -> Result<(), BlockchainError>
Locates a block in the chain and overwrites its txdata
Sourcepub fn remove_txdata(
&mut self,
hash: Sha256dHash,
) -> Result<(), BlockchainError>
pub fn remove_txdata( &mut self, hash: Sha256dHash, ) -> Result<(), BlockchainError>
Locates a block in the chain and removes its txdata
Sourcepub fn add_header(&mut self, header: BlockHeader) -> Result<(), BlockchainError>
pub fn add_header(&mut self, header: BlockHeader) -> Result<(), BlockchainError>
Adds a block header to the chain
Sourcepub fn add_block(&mut self, block: Block) -> Result<(), BlockchainError>
pub fn add_block(&mut self, block: Block) -> Result<(), BlockchainError>
Adds a block to the chain
Sourcepub fn genesis_hash(&self) -> Sha256dHash
pub fn genesis_hash(&self) -> Sha256dHash
Returns the genesis block’s blockhash
Sourcepub fn best_tip_height(&self) -> u32
pub fn best_tip_height(&self) -> u32
Returns the best tip height
Sourcepub fn best_tip_hash(&self) -> Sha256dHash
pub fn best_tip_hash(&self) -> Sha256dHash
Returns the best tip’s blockhash
Sourcepub fn locator_hashes(&self) -> Vec<Sha256dHash>
pub fn locator_hashes(&self) -> Vec<Sha256dHash>
Returns an array of locator hashes used in getheaders
messages
Sourcepub fn iter(&self, start_hash: Sha256dHash) -> BlockIter<'_> ⓘ
pub fn iter(&self, start_hash: Sha256dHash) -> BlockIter<'_> ⓘ
An iterator over all blocks in the chain starting from start_hash
Sourcepub fn rev_iter(&self, start_hash: Sha256dHash) -> RevBlockIter<'_> ⓘ
pub fn rev_iter(&self, start_hash: Sha256dHash) -> RevBlockIter<'_> ⓘ
An iterator over all blocks in reverse order to the genesis, starting with start_hash
Sourcepub fn rev_stale_iter(&self, start_hash: Sha256dHash) -> RevStaleBlockIter<'_> ⓘ
pub fn rev_stale_iter(&self, start_hash: Sha256dHash) -> RevStaleBlockIter<'_> ⓘ
An iterator over all blocks -not- in the best chain, in reverse order, starting from start_hash
Trait Implementations§
Source§impl<D: Decoder> Decodable<D> for Blockchain
impl<D: Decoder> Decodable<D> for Blockchain
Source§fn consensus_decode(d: &mut D) -> Result<Blockchain, Error>
fn consensus_decode(d: &mut D) -> Result<Blockchain, Error>
Decode an object with a well-defined format
Source§impl<S: Encoder> Encodable<S> for Blockchain
impl<S: Encoder> Encodable<S> for Blockchain
impl Send for Blockchain
Auto Trait Implementations§
impl Freeze for Blockchain
impl RefUnwindSafe for Blockchain
impl !Sync for Blockchain
impl Unpin for Blockchain
impl UnwindSafe for Blockchain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more