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: Suberhabitat 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: IoDupSuberInsertion 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: IoDupSuberPartially witnessed escrow: snKey(pre, sn) -> said of the escrowed event
(keripy .pwes).
ooes: IoDupSuberOut-of-order escrow: snKey(pre, sn) -> said of an event whose prior
event isn’t accepted yet (keripy .ooes).
ldes: IoDupSuberLikely 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: IoDupSuberUnverified 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: IoDupSuberUnverified 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
impl Baser
Sourcepub const MAX_NAMED_DBS: u32 = 10
pub const MAX_NAMED_DBS: u32 = 10
Maximum number of named databases
pub fn get_ke_last<K>(&self, key: K) -> Result<Option<String>, KERIError>
pub fn get_evt<K>(&self, key: K) -> Result<Option<Vec<u8>>, KERIError>
Sourcepub fn ri_key(pre: &str, ri: u64) -> String
pub fn ri_key(pre: &str, ri: u64) -> String
Create a key to access the pubs database with prefix and rotation index
pub fn fetch_all_sealing_event_by_event_seal( &self, _pre: &str, _anchor: &str, ) -> Result<bool, DBError>
Sourcepub fn fetch_last_sealing_event_by_event_seal(
&self,
pre: &str,
seal: &SealEvent,
sn: u64,
toad: usize,
) -> Result<Option<SerderKERI>, KERIError>
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.
Sourcepub fn wig_count(&self, pre: &str, said: &str) -> Result<usize, KERIError>
pub fn wig_count(&self, pre: &str, said: &str) -> Result<usize, KERIError>
Number of witness signatures stored for event said of pre.
Sourcepub fn clone_evt_msg_at(&self, pre: &str, sn: u64) -> Result<Vec<u8>, KERIError>
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.
Sourcepub fn clone_pre_iter(
&self,
pre: &str,
fn_num: Option<u64>,
) -> Result<Vec<Vec<u8>>, DBError>
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 stringfn_num- Optional first seen number to resume replay. Default is 0
§Returns
Result<Vec<Vec<u8>>, DBError>- Collection of messages with prefixprestarting atfn_num
Sourcepub fn clone_delegation(
&self,
kever: &Kever,
kevers: &HashMap<String, Kever>,
) -> Result<Vec<Vec<u8>>, DBError>
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
Sourcepub fn get_fel_item_all_pre_iter(
&self,
) -> Result<Vec<(String, u64, String)>, DBError>
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
Sourcepub fn clone_all_pre_iter(&self) -> Result<Vec<Vec<u8>>, DBError>
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
pub fn get_sigs_iter( &self, key: &[u8], ) -> Result<impl Iterator<Item = Result<Vec<u8>, DBError>>, DBError>
Sourcepub fn fetch_tsgs(
&self,
saider: Saider,
snh: Option<&str>,
) -> Result<Vec<(Prefixer, Seqner, Diger, Vec<Siger>)>, KERIError>
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 attachedsnh- Optional sequence number hex string for filtering
§Returns
Ok(Vec<(Prefixer, Seqner, Diger, Vec<Siger>)>)- List of signature groupsErr(KERIError)- On database error or parsing failure