Skip to main content

HistoryReader

Struct HistoryReader 

Source
pub struct HistoryReader { /* private fields */ }
Expand description

History reader. New segments and groups become visible after refresh; get calls it itself when the ledger is past the known end.

Implementations§

Source§

impl HistoryReader

Source

pub fn open(dir: &Path) -> Result<HistoryReader, String>

Source

pub fn cold_index(&self) -> Shared

Cold history indexes for the API (transaction by hash, account history, ledger hash).

Source

pub fn with_cold_cache(self, bytes: usize) -> Result<HistoryReader, String>

A smaller cold block cache, for a reader that goes through history once and must not take the memory the API’s reader uses.

Source

pub fn with_cold_first(self, on: bool) -> HistoryReader

Cold segments before hot ones: checks the cold history against the same queries.

Source

pub fn cold_info(&self) -> Vec<(u32, u32, Value)>

Cold segments: (first ledger, last ledger, manifest).

Source

pub fn with_prev(self, prev: Arc<PrevAt>) -> HistoryReader

Where to get previous object versions for format 3 changes, usually the state store.

Source

pub fn segments_info(&self) -> Vec<(u32, u32, bool)>

Segments: (first ledger, last ledger, format 3 changes). For a segment with no group written yet, last is one less than first.

Source

pub fn refresh(&self) -> Result<(), String>

Source

pub fn refresh_cold_every(&self, every: Duration) -> Result<(), String>

Reloads cold segments and indexes if every has passed since the last check: cold history is published into the live directory without a restart, and the hot misses that trigger refresh never reach it.

Source

pub fn first(&self) -> Option<u32>

Source

pub fn last(&self) -> Option<u32>

Last ledger with both streams written (or a cold one).

Source

pub fn cold_header(&self, seq: u32) -> Result<Option<Vec<u8>>, String>

Header of a ledger in cold history only, without decoding its transactions; None if the ledger isn’t in cold history.

Source

pub fn cold_transactions( &self, wants: &[(u32, u32)], ) -> Result<HashMap<u32, Ledger>, String>

Cold ledgers holding only the asked transactions (ledger, TransactionIndex) and their headers, read in parallel by block. Ledgers that hot history files hold are left out, as are ledgers cold history doesn’t have: get_txs_known serves those.

Source

pub fn ledgers_txs(&self, seqs: &[u32]) -> Result<Vec<Option<Ledger>>, String>

Several ledgers without state changes, in the order asked; None for one the history doesn’t hold. Cold ones are read in parallel by block.

Source

pub fn get_txs(&self, seq: u32) -> Result<Option<Ledger>, String>

A ledger without state changes (header and transactions), for the API.

Source

pub fn get_txs_known(&self, seq: u32) -> Result<Option<Ledger>, String>

Same, but only from already known segments, without rescanning the directory. Fresh ledgers not yet in the history are looked up among the store’s pending ones, not by walking files on every request.

Source

pub fn get(&self, seq: u32) -> Result<Option<Vec<u8>>, String>

A whole ledger in Ledger::encode serialization.

Source

pub fn convert_changes( &self, first: u32, group: u32, level: i32, ) -> Result<(u64, u64), String>

Rewrites the changes of the segment starting at first into format 3: writes *.new alongside, then reads every ledger back and compares it byte for byte with the original. swap_changes replaces the files. Returns the size of the old and new changes data.

Source

pub fn swap_changes(dir: &Path, first: u32) -> Result<(), String>

Replaces a segment’s changes with the ones prepared by convert_changes, with writing and reading stopped.

Two renames are not atomic, so the swap is journaled: both new halves in place → marker chg-F.swap with fsync → data → index → directory fsync → marker removed. If it crashes midway, recover_swaps finishes the swap when the history is opened: by then the new pair is written, synced and verified, and an old half never exists without the marker.

Source

pub fn recover_swaps(dir: &Path) -> Result<usize, String>

Finishes change swaps that were interrupted midway.

Source

pub fn bytes_on_disk(&self) -> u64

Bytes taken by segments, indexes and dictionaries.

Trait Implementations§

Source§

impl Debug for HistoryReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

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> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more