pub struct DagStore { /* private fields */ }Expand description
In-memory DAG node store. Persisted to dag_root_offset/dag_root_length
in the Q42 v3 volume header.
Implementations§
Source§impl DagStore
impl DagStore
pub fn new() -> Self
Sourcepub fn genesis_node(
&mut self,
quins: &[NQuin],
author_did: u64,
timestamp_ms: u64,
message: &str,
) -> [u8; 32]
pub fn genesis_node( &mut self, quins: &[NQuin], author_did: u64, timestamp_ms: u64, message: &str, ) -> [u8; 32]
Create the genesis node (no parent).
Sourcepub fn commit_node(
&mut self,
parent_hash: [u8; 32],
quins: &[NQuin],
author_did: u64,
timestamp_ms: u64,
message: &str,
) -> [u8; 32]
pub fn commit_node( &mut self, parent_hash: [u8; 32], quins: &[NQuin], author_did: u64, timestamp_ms: u64, message: &str, ) -> [u8; 32]
Create a regular commit node chained from parent_hash.
Sourcepub fn fork_node(
&mut self,
disputed_hash: [u8; 32],
quins: &[NQuin],
author_did: u64,
timestamp_ms: u64,
message: &str,
) -> [u8; 32]
pub fn fork_node( &mut self, disputed_hash: [u8; 32], quins: &[NQuin], author_did: u64, timestamp_ms: u64, message: &str, ) -> [u8; 32]
Create a contestability fork from disputed_hash.
Marks the new node with FORK_DISPUTED.
Sourcepub fn write_branch_pointer(
&mut self,
branch_name: &str,
tip_hash: [u8; 32],
) -> NQuin
pub fn write_branch_pointer( &mut self, branch_name: &str, tip_hash: [u8; 32], ) -> NQuin
Point branch_name at tip_hash. Returns an NQuin encoding the pointer
for storage in BRANCHES_CONTEXT.
Sourcepub fn merge_node(
&mut self,
primary_parent: [u8; 32],
secondary_parent: [u8; 32],
quins: &[NQuin],
author_did: u64,
timestamp_ms: u64,
message: &str,
) -> ([u8; 32], [u8; 32])
pub fn merge_node( &mut self, primary_parent: [u8; 32], secondary_parent: [u8; 32], quins: &[NQuin], author_did: u64, timestamp_ms: u64, message: &str, ) -> ([u8; 32], [u8; 32])
Create a merge node spanning two parent branches.
Returns (primary_hash, secondary_hash):
primary_hash: the merge commit itself (parent_hash = primary_parent)secondary_hash: a MERGE_SECONDARY back-link node whosequins_merkleencodesprimary_hashso the two branches stay bidirectionally linked
Any conflict quins should be written to crate::provenance::CONTEST_CONTEXT
before or after calling this function.
Sourcepub fn nodes_as_of(&self, as_of_ms: u64) -> Vec<[u8; 32]>
pub fn nodes_as_of(&self, as_of_ms: u64) -> Vec<[u8; 32]>
Return all node hashes with timestamp ≤ as_of_ms (assertion-time snapshot).
Used by the SPARQL AS OF executor to reconstruct which DAG commits existed at a given point in time.
Sourcepub fn branch_tip(&self, branch_name: &str) -> Option<[u8; 32]>
pub fn branch_tip(&self, branch_name: &str) -> Option<[u8; 32]>
Return the current tip hash for branch_name, if set.
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize the store to bytes for embedding in a Q42 volume.
Format: [u64 node_count] ([u8;88] node_bytes)*
Sourcepub fn deserialize(bytes: &[u8]) -> Option<Self>
pub fn deserialize(bytes: &[u8]) -> Option<Self>
Deserialize from bytes previously written by serialize.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DagStore
impl RefUnwindSafe for DagStore
impl Send for DagStore
impl Sync for DagStore
impl Unpin for DagStore
impl UnsafeUnpin for DagStore
impl UnwindSafe for DagStore
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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<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