Struct lightning_signer::chain::tracker::ChainTracker
source · pub struct ChainTracker<L: ChainListener + Ord> {
pub headers: VecDeque<Headers>,
pub tip: Headers,
pub height: u32,
pub network: Network,
pub listeners: OrderedMap<L, ListenSlot>,
/* private fields */
}
Expand description
Track chain, with basic validation
Fields§
§headers: VecDeque<Headers>
headers past the tip
tip: Headers
tip header
height: u32
height
network: Network
The network
listeners: OrderedMap<L, ListenSlot>
listeners
Implementations§
source§impl<L: ChainListener + Ord> ChainTracker<L>
impl<L: ChainListener + Ord> ChainTracker<L>
sourcepub const MAX_REORG_SIZE: usize = 100usize
pub const MAX_REORG_SIZE: usize = 100usize
Maximum reorg size that we will accept
sourcepub fn new(
network: Network,
height: u32,
tip: Headers,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Result<Self, Error>
pub fn new( network: Network, height: u32, tip: Headers, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Result<Self, Error>
Create a new tracker
sourcepub fn restore(
headers: VecDeque<Headers>,
tip: Headers,
height: u32,
network: Network,
listeners: OrderedMap<L, ListenSlot>,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Self
pub fn restore( headers: VecDeque<Headers>, tip: Headers, height: u32, network: Network, listeners: OrderedMap<L, ListenSlot>, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Self
Restore a tracker
sourcepub fn from_genesis(
network: Network,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Self
pub fn from_genesis( network: Network, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Self
Create a tracker at genesis
sourcepub fn for_network(
network: Network,
node_id: PublicKey,
validator_factory: Arc<dyn ValidatorFactory>
) -> Self
pub fn for_network( network: Network, node_id: PublicKey, validator_factory: Arc<dyn ValidatorFactory> ) -> Self
Create a tracker for a network, from a checkpoint if exists or from genesis otherwise
sourcepub fn remove_block(&mut self, proof: TxoProof) -> Result<BlockHeader, Error>
pub fn remove_block(&mut self, proof: TxoProof) -> Result<BlockHeader, Error>
Remove block at tip due to reorg
sourcepub fn add_block(
&mut self,
header: BlockHeader,
proof: TxoProof
) -> Result<(), Error>
pub fn add_block( &mut self, header: BlockHeader, proof: TxoProof ) -> Result<(), Error>
Add a block, which becomes the new tip
sourcepub fn add_listener(
&mut self,
listener: L,
initial_txid_watches: OrderedSet<Txid>
)
pub fn add_listener( &mut self, listener: L, initial_txid_watches: OrderedSet<Txid> )
Add a listener and initialize the watched outpoint set
sourcepub fn add_listener_watches(
&mut self,
listener: L,
watches: OrderedSet<OutPoint>
)
pub fn add_listener_watches( &mut self, listener: L, watches: OrderedSet<OutPoint> )
Add more watches to a listener
Auto Trait Implementations§
impl<L> !RefUnwindSafe for ChainTracker<L>
impl<L> Send for ChainTracker<L>
impl<L> Sync for ChainTracker<L>
impl<L> Unpin for ChainTracker<L>
impl<L> !UnwindSafe for ChainTracker<L>
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