Skip to main content

Baser

Struct Baser 

Source
pub struct Baser {
Show 32 fields pub habs: Komer<HabitatRecord>, pub names: Suber, pub evts: Suber, pub fels: OnSuber, pub kels: OnIoDupSuber<Utf8Codec>, pub fons: CesrSuber<Number>, pub esrs: Komer<EventSourceRecord>, pub dtss: DupSuber, pub sdts: CesrSuber<Dater>, pub rpys: SerderSuber<SerderKERI>, pub ssgs: CatCesrIoSetSuber<Siger>, pub scgs: CatCesrIoSetSuber<Verfer>, pub rpes: CesrIoSetSuber<Saider>, pub aess: Suber, pub sigs: DupSuber, pub wigs: DupSuber, pub wits: IoDupSuber, pub rcts: DupSuber, pub vrcs: DupSuber, pub states: Komer<KeyStateRecord>, pub locs: Komer<LocationRecord>, pub ends: Komer<EndpointRecord>, pub eans: CesrSuber<Saider>, pub lans: CesrSuber<Saider>, pub pses: IoDupSuber, pub pwes: IoDupSuber, pub ooes: IoDupSuber, pub ldes: IoDupSuber, pub misfits: IoDupSuber, pub delegables: IoDupSuber, pub ures: IoDupSuber, pub uwes: IoDupSuber, /* private fields */
}
Expand description

Baser struct for key event log and escrow storage (DB) Sets up named sub databases for key event logs and escrow storage.

Fields§

§habs: Komer<HabitatRecord>

habitat application state keyed by habitat name, includes prefix

§names: Suber

habitat name database mapping (domain,name) as key to Prefixer

§evts: Suber

.evts is named sub DB whose values are serialized key events dgKey DB is keyed by identifier prefix plus digest of serialized event Only one value per DB key is allowed

§fels: OnSuber

.fels is named sub DB of first seen event logs (FEL) as indices that map first seen ordinal number to digests. Actual serialized key events are stored in .evts by SAID digest This indexes events in first ‘seen’ accepted order for replay and cloning of event log. Uses first seen order number or fn. fnKey DB is keyed by identifier prefix plus monotonically increasing first seen order number fn. Value is digest of serialized event used to lookup event in .evts sub DB Only one value per DB key is allowed. Provides append only ordering of accepted first seen events.

§kels: OnIoDupSuber<Utf8Codec>

.kels is named sub DB of key event logs as indices that map sequence numbers to serialized key event digests. Actual serialized key events are stored in .evts by SAID digest Uses sequence number or sn. snKey Values are digests used to lookup event in .evts sub DB DB is keyed by identifier prefix plus sequence number of key event More than one value per DB key is allowed

§fons: CesrSuber<Number>

.fons is named subDB CesrSuber Uses digest dgKey Maps prefix and digest to fn value (first seen ordinal number) of the associated event. So one used pre and event digest, get its fn here and then use fn to fetch event from .evnts by fn from .fels. This ensures that any event looked up this way was first seen at some point in time even if later superseded by a recovery rotation. Whereas direct lookup in .evts could be escrowed events that may never have been accepted as first seen. CesrSuber(db=self, subkey=‘fons.’, klas=core.Number)

§esrs: Komer<EventSourceRecord>

.esrs is named sub DB instance of Komer of EventSourceRecord dgKey DB is keyed by identifier prefix plus digest (said) of serialized event Value is serialized instance of EventSourceRecord dataclass. Only one value per DB key is allowed. Keeps track of the source of the event. When .local is Truthy the event was sourced in a protected way such as being generated locally or via a protected path. When .local is Falsey the event was NOT sourced in a protected way. The value of .local determines what validation logic to run on the event. This database is used to track the source when processing escrows that would otherwise be decoupled from the original source of the event.

§dtss: DupSuber

.dtss is named sub DB of datetime stamp strings in ISO 8601 format of the datetime when the event was first escrosed and then later first seen by log. Used for escrows timeouts and extended validation. dgKey DB is keyed by identifier prefix plus digest of serialized event Value is ISO 8601 datetime stamp bytes

§sdts: CesrSuber<Dater>

.sdts (sad date-time-stamp) named subDB instance of CesrSuber that maps SAD SAID to Dater instance’s CESR serialization of ISO-8601 datetime key = said (bytes) of sad, val = dater.qb64b

§rpys: SerderSuber<SerderKERI>

.rpys (replys) named subDB instance of SerderSuber that maps said of reply message (versioned SAD) to serialization of that reply message. key is said bytes, val is Serder.raw bytes of reply ‘rpy’ message

§ssgs: CatCesrIoSetSuber<Siger>

.ssgs (sad trans indexed sigs) named subDB instance of CesrIoSetSuber that maps keys quadruple (saider.qb64, prefixer.qb64, seqner.q64, diger.qb64) to val Siger of trans id signature. Where: saider is said of SAD and prefixer, seqner, and diger indicate the key state est event for signer or reply SAD. Each key may have a set of vals in insertion order one for each signer of the sad. key = join (saider.qb64b, prefixer.qb64b, seqner.qb64b, diger.qb64b) (bytes) val = siger.qb64b

§scgs: CatCesrIoSetSuber<Verfer>

.scgs (sad nontrans cigs) named subDB instance of CatCesrIoSetSuber that maps said of SAD to couple (Verfer, Cigar) for nontrans signer. For nontrans qb64 of Verfer is same as Prefixer. Each key may have a set of vals in insertion order one for each nontrans signer of the sad. key = said (bytes) of SAD, val = cat of (verfer.qb64, cigar.qb64b)

§rpes: CesrIoSetSuber<Saider>

.rpes (reply escrows) named subDB instance of CesrIoSetSuber that maps routes of reply (versioned SAD) to single Saider of that reply msg. Routes such as ‘/end/role/’ and ‘/loc/scheme’ key is route bytes, vals = saider.qb64b of reply ‘rpy’ msg

§aess: Suber

.aess is named sub DB of authorizing event source seal couples that map digest to seal source couple of authorizer’s (delegator or issuer) event. Each couple is a concatenation of full qualified items, snu+dig of the authorizing (delegating or issuing) source event. dgKey Values are couples used to lookup authorizer’s source event in .kels sub DB DB is keyed by identifier prefix plus digest of key event Only one value per DB key is allowed

§sigs: DupSuber

.sigs is named sub DB of fully qualified indexed event signatures dgKey DB is keyed by identifier prefix plus digest of serialized event More than one value per DB key is allowed

§wigs: DupSuber

.wigs is named sub DB of indexed witness signatures of event that may come directly or derived from a witness receipt message. Witnesses always have nontransferable identifier prefixes. The index is the offset of the witness into the witness list of the most recent establishment event wrt the receipted event. dgKey DB is keyed by identifier prefix plus digest of serialized event More than one value per DB key is allowed

§wits: IoDupSuber

Insertion order set of witnesses qb64 prefix

§rcts: DupSuber

.rcts is named sub DB of event receipt couplets from nontransferable signers. These are endorsements from nontrasferable signers who are not witnesses May be watchers or other Each couple is concatenation of fully qualified items. These are: non-transferale prefix plus non-indexed event signature by that prefix. dgKey DB is keyed by identifier prefix plus digest of serialized event More than one value per DB key is allowed

§vrcs: DupSuber

.vrcs is named sub DB of event validator receipt quadruples from transferable signers. Each quadruple is concatenation of four fully qualified items of validator. These are: transferable prefix, plus latest establishment event sequence number plus latest establishment event digest, plus indexed event signature. These are endorsements by transferable AIDs that are not the controller may be watchers or others. When latest establishment event is multisig then there will be multiple quadruples one per signing key, each a dup at same db key. dgKey DB is keyed by identifier prefix plus digest of serialized event More than one value per DB key is allowed

§states: Komer<KeyStateRecord>

Prefix situation database Key is identifier prefix (fully qualified qb64) Value is serialized parameter dict of public key situation

§locs: Komer<LocationRecord>§ends: Komer<EndpointRecord>§eans: CesrSuber<Saider>§lans: CesrSuber<Saider>§pses: IoDupSuber§pwes: IoDupSuber

Partially witnessed escrow: snKey(pre, sn) -> said of the escrowed event (keripy .pwes).

§ooes: IoDupSuber

Out-of-order escrow: snKey(pre, sn) -> said of an event whose prior event isn’t accepted yet (keripy .ooes).

§ldes: IoDupSuber

Likely duplicitous escrow: snKey(pre, sn) -> said of an event that conflicts with one already accepted at that sn (keripy .ldes).

§misfits: IoDupSuber

.misfits: events from a remote source for an identifier that is locally owned, witnessed or delegated (keripy misfits, “mfes.”). snKey -> event SAID. They wait for the local owner to decide; nothing processes them automatically (as in keripy).

§delegables: IoDupSuber

.delegables: delegated events, for a locally owned delegator, that have no approval yet (keripy delegables, “dees.”). snKey -> event SAID. The delegator approves them with Habery::approve_delegation.

§ures: IoDupSuber

Unverified receipt escrow: snKey(pre, sn) -> said + receiptor prefix + cigar of a non-transferable receipt whose event is not yet in the KEL (keripy .ures).

§uwes: IoDupSuber

Unverified witness receipt escrow: snKey(pre, sn) -> said + wig of an indexed witness receipt whose event is not yet in the KEL (keripy .uwes).

Implementations§

Source§

impl Baser

Source

pub const MAX_NAMED_DBS: u32 = 10

Maximum number of named databases

Source

pub fn new(lmdber: Arc<LMDBer>) -> Result<Self, DBError>

Create a new Keeper instance

Source

pub fn get_ke_last<K>(&self, key: K) -> Result<Option<String>, KERIError>
where K: AsRef<[u8]>,

Source

pub fn get_evt<K>(&self, key: K) -> Result<Option<Vec<u8>>, KERIError>
where K: AsRef<[u8]>,

Source

pub fn opened(&self) -> bool

Check if database is opened

Source

pub fn name(&self) -> String

Get name of database

Source

pub fn path(&self) -> Option<PathBuf>

Get database path

Source

pub fn temp(&self) -> bool

Close the database Check if database is temporary

Source

pub fn ri_key(pre: &str, ri: u64) -> String

Create a key to access the pubs database with prefix and rotation index

Source

pub fn fetch_all_sealing_event_by_event_seal( &self, _pre: &str, _anchor: &str, ) -> Result<bool, DBError>

Source

pub fn fetch_last_sealing_event_by_event_seal( &self, pre: &str, seal: &SealEvent, sn: u64, toad: usize, ) -> Result<Option<SerderKERI>, KERIError>

The last (not superseded) event in pre’s KEL at or after sn that anchors seal and is fully witnessed, i.e. has at least toad witness signatures (keripy: db/basing.py Baser.fetchLastSealingEventByEventSeal).

keripy reads toad from the KEL’s current key state (Baser.fullyWitnessed); the caller passes it because the Baser does not hold the Kevers here. Only an exact {i, s, d} event seal matches.

Source

pub fn wig_count(&self, pre: &str, said: &str) -> Result<usize, KERIError>

Number of witness signatures stored for event said of pre.

Source

pub fn clone_evt_msg_at(&self, pre: &str, sn: u64) -> Result<Vec<u8>, KERIError>

The accepted event of pre at sn as a message with all its attachments (signatures, witness signatures, source seal couple, first seen couple), as keripy cloneEvtMsg writes it.

Source

pub fn clone_pre_iter( &self, pre: &str, fn_num: Option<u64>, ) -> Result<Vec<Vec<u8>>, DBError>

Returns an iterator of first seen event messages with attachments for the identifier prefix pre starting at first seen order number, fn_num. Essentially a replay in first seen order with attachments.

§Parameters
  • pre - Identifier prefix as string
  • fn_num - Optional first seen number to resume replay. Default is 0
§Returns
  • Result<Vec<Vec<u8>>, DBError> - Collection of messages with prefix pre starting at fn_num
Source

pub fn clone_delegation( &self, kever: &Kever, kevers: &HashMap<String, Kever>, ) -> Result<Vec<Vec<u8>>, DBError>

Recursively clone delegation chain from AID of Kever if one exists.

This method yields messages in the correct order: first the delegator’s delegation chain (if any), then all events from the delegator’s key event log.

§Parameters
  • kever - Kever from which to clone the delegator’s AID
§Returns
  • Result<Vec<Vec<u8>>, DBError> - Collection of messages representing the delegation chain
Source

pub fn clone_evt_msg( &self, pre: &str, fn_num: u64, dig: &str, ) -> Result<Vec<u8>, DBError>

Clones Event as Serialized CESR Message with Body and attached Foot

§Parameters
  • pre - Identifier prefix of event
  • fn_num - First seen number (ordinal) of event
  • dig - Digest of event
§Returns
  • Result<Vec<u8>, DBError> - Message body with attachments
Source

pub fn get_fel_item_all_pre_iter( &self, ) -> Result<Vec<(String, u64, String)>, DBError>

Returns iterator of all (pre, fn, dig) triples in first seen order for all events for all prefixes in database. Items are sorted by fnKey(pre, fn) where fn is first seen order number int. Returns all First Seen Event Logs FELs.

Returned items are triples of (pre, fn, dig): Where pre is identifier prefix, fn is first seen order number int and dig is event digest for lookup in .evts sub db.

§Returns
  • Result<Vec<(String, u64, String)>, DBError> - Collection of (prefix, fn, digest) triples
Source

pub fn clone_all_pre_iter(&self) -> Result<Vec<Vec<u8>>, DBError>

Returns iterator of first seen event messages with attachments for all identifier prefixes starting at the beginning of the database. Essentially a replay in first seen order with attachments of entire set of FELs (First Seen Event Logs).

§Returns
  • Result<Vec<Vec<u8>>, DBError> - Collection of all event messages with attachments
Source

pub fn cnt_sigs(&self, key: &[u8]) -> Result<usize, DBError>

Return count of signatures at key. Uses dgKey format for the key. Returns zero if no entry at key.

§Parameters
  • key - The key to count signatures for (should be in dgKey format)
§Returns
  • Result<usize, DBError> - Count of signatures, zero if no entry
Source

pub fn get_sigs_iter( &self, key: &[u8], ) -> Result<impl Iterator<Item = Result<Vec<u8>, DBError>>, DBError>

Source

pub fn fetch_tsgs( &self, saider: Saider, snh: Option<&str>, ) -> Result<Vec<(Prefixer, Seqner, Diger, Vec<Siger>)>, KERIError>

Fetch transferable signature groups from the ssgs database

§Parameters
  • saider - SAID for the reply to which signatures are attached
  • snh - Optional sequence number hex string for filtering
§Returns
  • Ok(Vec<(Prefixer, Seqner, Diger, Vec<Siger>)>) - List of signature groups
  • Err(KERIError) - On database error or parsing failure

Trait Implementations§

Source§

impl Filer for Baser

Source§

const TAIL_DIR_PATH: &'static str = "keri/db"

Default relative directory path tail when using head
Source§

const ALT_TAIL_DIR_PATH: &'static str = ".keri/db"

Default alternative relative directory path tail as fallback
Source§

const TEMP_PREFIX: &'static str = "keri_db_"

Default relative directory path prefix when using temp head
Source§

fn defaults() -> FilerDefaults

Source§

const HEAD_DIR_PATH: &'static str = "/usr/local/var"

Default absolute directory path head such as “/usr/local/var”
Source§

const CLEAN_TAIL_DIR_PATH: &'static str = "keri/clean"

Default relative directory path tail when creating clean
Source§

const ALT_CLEAN_TAIL_DIR_PATH: &'static str = ".keri/clean"

Default alternative relative path tail when creating clean
Source§

const TEMP_HEAD_DIR: &'static str = "/tmp"

Default relative directory path prefix when using temp head
Source§

const PERM: u32 = 0o1700

Explicit default octal permissions such as 0o1700
Source§

const MODE: &'static str = "r+"

Open mode such as “r+”
Source§

const FEXT: &'static str = "text"

Default file extension such as “text” for “fname.text”

Auto Trait Implementations§

§

impl Freeze for Baser

§

impl RefUnwindSafe for Baser

§

impl Send for Baser

§

impl Sync for Baser

§

impl Unpin for Baser

§

impl UnsafeUnpin for Baser

§

impl UnwindSafe for Baser

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
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.

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