Struct bitcoin_index::BaseIndex
source · 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
impl BaseIndex
pub fn current_index(&mut self) -> *const BlockIndex
pub fn init(&mut self) -> bool
sourcepub fn thread_sync(&mut self)
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.
sourcepub fn commit(&mut self) -> bool
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.
pub fn commit_internal(&mut self, batch: &mut DBBatch) -> bool
pub fn rewind( &mut self, current_tip: *const BlockIndex, new_tip: *const BlockIndex ) -> bool
pub fn block_connected(&mut self, block: &Arc<Block>, pindex: *const BlockIndex)
pub fn chain_state_flushed(&mut self, locator: &BlockLocator)
sourcepub fn block_until_synced_to_current_chain(&self) -> bool
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.
pub fn interrupt(&mut self)
sourcepub fn start(&mut self, active_chainstate: &mut dyn ChainStateInterface) -> bool
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.
sourcepub fn get_summary(&self) -> IndexSummary
pub fn get_summary(&self) -> IndexSummary
| Get a summary of the index and its state. |