pub enum HeightStrategy {
Incremental,
Timestamp,
}Expand description
Height calculation strategy for entries in a database.
The height of an entry determines its position in the causal ordering of the Merkle DAG. Different strategies provide different trade-offs:
Incremental: Simple monotonic counter, optimal for offline-firstTimestamp: Time-aware ordering
§Database Configuration
Height strategy is configured at the database level and stored in
_settings.height_strategy. All transactions from a database inherit
the strategy. The strategy should be set at database creation time.
Variants§
Incremental
Incremental height: height = max(parent_heights) + 1
Root entries have height 0. Each subsequent entry has height equal to the maximum height of its parents plus one.
This is the default strategy and provides optimal behavior for offline-first scenarios where entries may be created without network connectivity.
Timestamp
Timestamp-based height: height = max(current_timestamp_ms, max(parent_heights) + 1)
Uses milliseconds since Unix epoch as the height value, ensuring entries are ordered by creation time while maintaining monotonic progression (never less than parent height + 1).
This strategy is useful for:
- Time-series data where temporal ordering matters
- Debugging and auditing (heights indicate creation time)
- Scenarios where clock synchronization is reasonable
Note: Requires reasonably synchronized clocks across clients. Clock skew may cause entries to have heights slightly in the future relative to other clients. Use caution.
Trait Implementations§
Source§impl Clone for HeightStrategy
impl Clone for HeightStrategy
Source§fn clone(&self) -> HeightStrategy
fn clone(&self) -> HeightStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HeightStrategy
impl Debug for HeightStrategy
Source§impl Default for HeightStrategy
impl Default for HeightStrategy
Source§fn default() -> HeightStrategy
fn default() -> HeightStrategy
Source§impl<'de> Deserialize<'de> for HeightStrategy
impl<'de> Deserialize<'de> for HeightStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for HeightStrategy
impl PartialEq for HeightStrategy
Source§impl Serialize for HeightStrategy
impl Serialize for HeightStrategy
impl Copy for HeightStrategy
impl Eq for HeightStrategy
impl StructuralPartialEq for HeightStrategy
Auto Trait Implementations§
impl Freeze for HeightStrategy
impl RefUnwindSafe for HeightStrategy
impl Send for HeightStrategy
impl Sync for HeightStrategy
impl Unpin for HeightStrategy
impl UnwindSafe for HeightStrategy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more