mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Merge pull request #1777 from lexe-tech/max/best-block-header-best-block
Add `.to_best_block()` method to `ValidatedBlockHeader`
This commit is contained in:
commit
ee17faff90
1 changed files with 14 additions and 0 deletions
|
@ -4,6 +4,7 @@ use crate::{AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource, Blo
|
|||
|
||||
use bitcoin::hash_types::BlockHash;
|
||||
use bitcoin::network::constants::Network;
|
||||
use lightning::chain::BestBlock;
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
|
@ -146,6 +147,19 @@ impl ValidatedBlockHeader {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the [`BestBlock`] corresponding to this validated block header, which can be passed
|
||||
/// into [`ChannelManager::new`] as part of its [`ChainParameters`]. Useful for ensuring that
|
||||
/// the [`SpvClient`] and [`ChannelManager`] are initialized to the same block during a fresh
|
||||
/// start.
|
||||
///
|
||||
/// [`SpvClient`]: crate::SpvClient
|
||||
/// [`ChainParameters`]: lightning::ln::channelmanager::ChainParameters
|
||||
/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
|
||||
/// [`ChannelManager::new`]: lightning::ln::channelmanager::ChannelManager::new
|
||||
pub fn to_best_block(&self) -> BestBlock {
|
||||
BestBlock::new(self.block_hash, self.inner.height)
|
||||
}
|
||||
}
|
||||
|
||||
/// A block with validated data against its transaction list and corresponding block hash.
|
||||
|
|
Loading…
Add table
Reference in a new issue