pub struct BaseIndex { /* private fields */ }
Expand description

| Base class for indices of blockchain | data. This implements | | CValidationInterface and ensures | blocks are indexed sequentially according | to their position in the active chain. |

Implementations§

source§

impl BaseIndex

source

pub fn current_index(&mut self) -> *const BlockIndex

source

pub fn init(&mut self) -> bool

source

pub fn thread_sync(&mut self)

| Sync the index with the block index | starting from the current best block. | | Intended to be run in its own thread, | m_thread_sync, and can be interrupted with | m_interrupt. Once the index gets in sync, | the m_synced flag is set and the | BlockConnected ValidationInterface | callback takes over and the sync thread | exits.

source

pub fn commit(&mut self) -> bool

| Write the current index state (eg. chain | block locator and subclass-specific items) | to disk. | | Recommendations for error handling: | | If called on a successor of the previous | committed best block in the index, the | index can continue processing without risk | of corruption, though the index state will | need to catch up from further behind on | reboot. If the new state is not | a successor of the previous state (due to | a chain reorganization), the index must | halt until Commit succeeds or else it | could end up getting corrupted.

source

pub fn commit_internal(&mut self, batch: &mut DBBatch) -> bool

source

pub fn rewind( &mut self, current_tip: *const BlockIndex, new_tip: *const BlockIndex ) -> bool

source

pub fn block_connected(&mut self, block: &Arc<Block>, pindex: *const BlockIndex)

source

pub fn chain_state_flushed(&mut self, locator: &BlockLocator)

source

pub fn block_until_synced_to_current_chain(&self) -> bool

| Blocks the current thread until the index | is caught up to the current state of the | block chain. This only blocks if the index | has gotten in sync once and only needs to | process blocks in the ValidationInterface | queue. If the index is catching up from | far behind, this method does not block and | immediately returns false.

source

pub fn interrupt(&mut self)

source

pub fn start(&mut self, active_chainstate: &mut dyn ChainStateInterface) -> bool

| Start initializes the sync state and | registers the instance as | a ValidationInterface so that it stays in | sync with blockchain updates.

source

pub fn stop(&mut self)

| Stops the instance from staying in sync | with blockchain updates. |

source

pub fn get_summary(&self) -> IndexSummary

| Get a summary of the index and its state. |

Trait Implementations§

source§

impl BlockChecked for BaseIndex

source§

fn block_checked(self: Arc<Self>, _0: &Block, _1: &BlockValidationState)

| Notifies listeners of a block validation | result. | | If the provided BlockValidationState | IsValid, the provided block is guaranteed | to be the current best block at the time | the callback was generated (not necessarily | now) |
source§

impl BlockConnected for BaseIndex

source§

fn block_connected(&mut self, block: Arc<Block>, pindex: Arc<BlockIndex>)

| Notifies listeners of a block being | connected. | | Provides a vector of transactions evicted | from the mempool as a result. | | Called on a background thread. |
source§

impl BlockDisconnected for BaseIndex

source§

fn block_disconnected(&mut self, block: Arc<Block>, pindex: Arc<BlockIndex>)

| Notifies listeners of a block being | disconnected | | Called on a background thread. |
source§

impl ChainStateFlushed for BaseIndex

source§

fn chain_state_flushed(&mut self, locator: &BlockLocator)

| Notifies listeners of the new active | block chain on-disk. | | Prior to this callback, any updates | are not guaranteed to persist on disk | (ie clients need to handle shutdown/restart | safety by being able to understand when | some updates were lost due to unclean | shutdown). | | When this callback is invoked, the validation | changes done by any prior callback are | guaranteed to exist on disk and survive | a restart, including an unclean shutdown. | | Provides a locator describing the best | chain, which is likely useful for storing | current state on disk in client DBs. | | Called on a background thread. |
source§

impl Drop for BaseIndex

source§

fn drop(&mut self)

| Destructor interrupts sync thread | if running and blocks until it exits. |

source§

impl NewPoWValidBlock for BaseIndex

source§

fn new_pow_valid_block(&mut self, pindex: Arc<BlockIndex>, block: &Arc<Block>)

| Notifies listeners that a block which | builds directly on our current tip has | been received and connected to the headers | tree, though not validated yet |
source§

impl TransactionAddedToMempool for BaseIndex

source§

fn transaction_added_to_mempool( &mut self, tx: &Amo<Transaction>, mempool_sequence: u64 )

| Notifies listeners of a transaction | having been added to mempool. | | Called on a background thread. |
source§

impl TransactionRemovedFromMempool for BaseIndex

source§

fn transaction_removed_from_mempool( &mut self, tx: &Amo<Transaction>, reason: MemPoolRemovalReason, mempool_sequence: u64 )

| Notifies listeners of a transaction | leaving mempool. | | This notification fires for transactions | that are removed from the mempool for | the following reasons: | | - EXPIRY (expired from mempool after | -mempoolexpiry hours) | | - SIZELIMIT (removed in size limiting | if the mempool exceeds -maxmempool | megabytes) | | - REORG (removed during a reorg) | | - CONFLICT (removed because it conflicts | with in-block transaction) | | - REPLACED (removed due to RBF replacement) | | This does not fire for transactions | that are removed from the mempool because | they have been included in a block. Any | client that is interested in transactions | removed from the mempool for inclusion | in a block can learn about those transactions | from the BlockConnected notification. | | Transactions that are removed from | the mempool because they conflict with | a transaction in the new block will have | | TransactionRemovedFromMempool events | fired before the BlockConnected | event is fired. If multiple blocks are | connected in one step, then the ordering | could be: | | - TransactionRemovedFromMempool(tx1 | from block A) | | - TransactionRemovedFromMempool(tx2 | from block A) | | - TransactionRemovedFromMempool(tx1 | from block B) | | - TransactionRemovedFromMempool(tx2 | from block B) | | - BlockConnected(A) | | - BlockConnected(B) | | Called on a background thread. |
source§

impl UpdatedBlockTip for BaseIndex

source§

fn updated_block_tip( &mut self, pindex_new: Option<Arc<BlockIndex>>, pindex_fork: Option<Arc<BlockIndex>>, initial_download: bool )

| Notifies listeners when the block chain | tip advances. | | When multiple blocks are connected | at once, UpdatedBlockTip will be called | on the final tip but may not be called | on every intermediate tip. If the latter | behavior is desired, subscribe to BlockConnected() | instead. | | Called on a background thread. |
source§

impl ValidationInterface for BaseIndex

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V