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
impl HistoryReader
pub fn open(dir: &Path) -> Result<HistoryReader, String>
Sourcepub fn cold_index(&self) -> Shared
pub fn cold_index(&self) -> Shared
Cold history indexes for the API (transaction by hash, account history, ledger hash).
Sourcepub fn with_cold_cache(self, bytes: usize) -> Result<HistoryReader, String>
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.
Sourcepub fn with_cold_first(self, on: bool) -> HistoryReader
pub fn with_cold_first(self, on: bool) -> HistoryReader
Cold segments before hot ones: checks the cold history against the same queries.
Sourcepub fn cold_info(&self) -> Vec<(u32, u32, Value)>
pub fn cold_info(&self) -> Vec<(u32, u32, Value)>
Cold segments: (first ledger, last ledger, manifest).
Sourcepub fn with_prev(self, prev: Arc<PrevAt>) -> HistoryReader
pub fn with_prev(self, prev: Arc<PrevAt>) -> HistoryReader
Where to get previous object versions for format 3 changes, usually the state store.
Sourcepub fn segments_info(&self) -> Vec<(u32, u32, bool)>
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.
pub fn refresh(&self) -> Result<(), String>
Sourcepub fn refresh_cold_every(&self, every: Duration) -> Result<(), String>
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.
pub fn first(&self) -> Option<u32>
Sourcepub fn cold_header(&self, seq: u32) -> Result<Option<Vec<u8>>, String>
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.
Sourcepub fn cold_transactions(
&self,
wants: &[(u32, u32)],
) -> Result<HashMap<u32, Ledger>, String>
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.
Sourcepub fn ledgers_txs(&self, seqs: &[u32]) -> Result<Vec<Option<Ledger>>, String>
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.
Sourcepub fn get_txs(&self, seq: u32) -> Result<Option<Ledger>, String>
pub fn get_txs(&self, seq: u32) -> Result<Option<Ledger>, String>
A ledger without state changes (header and transactions), for the API.
Sourcepub fn get_txs_known(&self, seq: u32) -> Result<Option<Ledger>, String>
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.
Sourcepub fn get(&self, seq: u32) -> Result<Option<Vec<u8>>, String>
pub fn get(&self, seq: u32) -> Result<Option<Vec<u8>>, String>
A whole ledger in Ledger::encode serialization.
Sourcepub fn convert_changes(
&self,
first: u32,
group: u32,
level: i32,
) -> Result<(u64, u64), String>
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.
Sourcepub fn swap_changes(dir: &Path, first: u32) -> Result<(), String>
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.
Sourcepub fn recover_swaps(dir: &Path) -> Result<usize, String>
pub fn recover_swaps(dir: &Path) -> Result<usize, String>
Finishes change swaps that were interrupted midway.
Sourcepub fn bytes_on_disk(&self) -> u64
pub fn bytes_on_disk(&self) -> u64
Bytes taken by segments, indexes and dictionaries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HistoryReader
impl !RefUnwindSafe for HistoryReader
impl !UnwindSafe for HistoryReader
impl Send for HistoryReader
impl Sync for HistoryReader
impl Unpin for HistoryReader
impl UnsafeUnpin for HistoryReader
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].