pub struct Kever {
pub db: Arc<Baser>,
pub delpre: Option<String>,
pub verfers: Option<Vec<Verfer>>,
pub ndigers: Option<Vec<Diger>>,
/* private fields */
}Fields§
§db: Arc<Baser>§delpre: Option<String>§verfers: Option<Vec<Verfer>>§ndigers: Option<Vec<Diger>>Implementations§
Source§impl Kever
impl Kever
Sourcepub fn new(
db: Arc<Baser>,
locals: &Locals,
state: Option<KeyStateRecord>,
serder: Option<SerderKERI>,
sigers: Option<Vec<Siger>>,
wigers: Option<Vec<Siger>>,
est_only: Option<bool>,
delseqner: Option<Seqner>,
delsaider: Option<Saider>,
firner: Option<Seqner>,
dater: Option<Dater>,
eager: Option<bool>,
local: Option<bool>,
check: Option<bool>,
) -> Result<Self, KERIError>
pub fn new( db: Arc<Baser>, locals: &Locals, state: Option<KeyStateRecord>, serder: Option<SerderKERI>, sigers: Option<Vec<Siger>>, wigers: Option<Vec<Siger>>, est_only: Option<bool>, delseqner: Option<Seqner>, delsaider: Option<Saider>, firner: Option<Seqner>, dater: Option<Dater>, eager: Option<bool>, local: Option<bool>, check: Option<bool>, ) -> Result<Self, KERIError>
Create a new Kever instance for an inception event
§Arguments
state- Optional key state recordserder- Optional serialized event datasigers- Optional list of indexed controller signatureswigers- Optional list of indexed witness signaturesdb- LMDB database instanceest_only- Optional boolean, True means establishment only events alloweddelseqner- Optional delegating event sequence numberdelsaider- Optional delegating event SAIDfirner- Optional first seen ordinal numberdater- Optional first seen timestampcues- Optional queue for notices or requestseager- Optional boolean for eager validationlocal- Optional boolean for event source validation logiccheck- Optional boolean for database update control
§Returns
Result<Self, KERIError>- New Kever instance or error
Sourcepub fn locally_witnessed(
&self,
locals: &Locals,
wits: Option<&[String]>,
serder: Option<&SerderKERI>,
) -> bool
pub fn locally_witnessed( &self, locals: &Locals, wits: Option<&[String]>, serder: Option<&SerderKERI>, ) -> bool
Returns true if a local controller is a witness of this Kever’s KEL or the provided witness list
§Arguments
wits- Optional list of qb64 witness prefixes. If None, uses the current witnesses for this Keverserder- Optional SerderKERI instance. If provided, derives witnesses from it instead of current state
§Returns
true if any of the prefixes in self.prefixes is also in the witness list; false otherwise
Sourcepub fn derive_backs(
&self,
serder: &SerderKERI,
) -> Result<(Vec<String>, Vec<String>, Vec<String>), KERIError>
pub fn derive_backs( &self, serder: &SerderKERI, ) -> Result<(Vec<String>, Vec<String>, Vec<String>), KERIError>
Derives and returns tuple of (wits, cuts, adds) for backers given current set and any changes provided by serder.
§Arguments
serder- Instance of current event
§Returns
A tuple containing:
wits- List of witness prefixes (full list of backers)cuts- List of witnesses removed in latest establishment eventadds- List of witnesses added in latest establishment event
§Errors
Returns ValidationError if there are invalid combinations of witnesses, cuts, or adds
pub fn verfers(&self) -> Option<Vec<Verfer>>
pub fn sner(&self) -> Option<Number>
pub fn last_est(&self) -> Option<LastEstLoc>
Source§impl Kever
impl Kever
Sourcepub fn update(
&mut self,
locals: &Locals,
serder: SerderKERI,
sigers: Vec<Siger>,
wigers: Option<Vec<Siger>>,
delseqner: Option<Seqner>,
delsaider: Option<Saider>,
firner: Option<Seqner>,
dater: Option<Dater>,
eager: bool,
local: bool,
check: bool,
) -> Result<(), KERIError>
pub fn update( &mut self, locals: &Locals, serder: SerderKERI, sigers: Vec<Siger>, wigers: Option<Vec<Siger>>, delseqner: Option<Seqner>, delsaider: Option<Saider>, firner: Option<Seqner>, dater: Option<Dater>, eager: bool, local: bool, check: bool, ) -> Result<(), KERIError>
Not an inception event. Verify event serder and indexed signatures in sigers and update state
§Arguments
serder- Instance of eventsigers- List of SigMat instances of indexed signatures of controller signatures of event. Index is offset into keys list from latest est event and when provided index is offset into key digest list from prior next est event to latest est event.wigers- Optional list of Siger instances of indexed witness signatures of event. Index is offset into wits list from latest est eventdelseqner- Optional instance of delegating event sequence number. If this event is not delegated then seqner is ignoreddelsaider- Optional instance of delegating event said. If this event is not delegated then diger is ignoredfirner- Optional Seqner instance of cloned first seen ordinal If cloned mode then firner maybe provided (not None) When firner provided then compare fn of dater and database and first seen if not match then log and add cue notify problemdater- Optional Dater instance of cloned replay datetime If cloned mode then dater maybe provided (not None) When dater provided then use dater for first seen datetimeeager- If true, try harder to find validate events by walking KELs. Enables only being eager in escrow processing not initial parsing. If false, only use pre-existing information if any.local- Event source for validation logic. True means event source is local (protected). False means event source is remote (unprotected).check- If true, do not update the database in any non-idempotent way. Useful for reinitializing the Kevers from a persisted KEL without updating non-idempotent first seen .fels and timestamps.
§Returns
Result<(), KERIError>- Ok if successful, Error otherwise
Sourcepub fn rotate(
&self,
serder: &SerderKERI,
) -> Result<(Tholder, Number, Vec<String>, Vec<String>, Vec<String>), KERIError>
pub fn rotate( &self, serder: &SerderKERI, ) -> Result<(Tholder, Number, Vec<String>, Vec<String>, Vec<String>), KERIError>
Generic Rotate Operation Validation Processing Validates provisional rotation Same logic for both ‘rot’ and ‘drt’ (plain and delegated rotation)
§Arguments
serder- Instance of rotation (‘rot’ or ‘drt’) event.
§Returns
A tuple (tholder, toader, wits, cuts, adds) of provisional results of rotation subject to additional validation
§Errors
ValidationError- if the rotation event is invalidValueError- if the toad value is invalid
pub fn log_event( &self, locals: &Locals, serder: SerderKERI, sigers: Vec<Siger>, wigers: Option<Vec<Siger>>, wits: Option<Vec<String>>, first: bool, seqner: Option<Seqner>, saider: Option<Saider>, _firner: Option<Seqner>, dater: Option<Dater>, local: bool, ) -> Result<(Option<u64>, DateTime<Utc>), KERIError>
Sourcepub fn state(&self) -> Result<KeyStateRecord, KERIError>
pub fn state(&self) -> Result<KeyStateRecord, KERIError>
Returns KeyStateRecord instance of current key state
pub fn toader(&self) -> Option<Number>
pub fn wits(&self) -> Vec<String>
pub fn prefixer(&self) -> Option<Prefixer>
pub fn serder(&self) -> Option<SerderKERI>
pub fn delpre(&self) -> Option<String>
Sourcepub fn fetch_prior_digers(
&self,
sn: Option<u64>,
) -> Result<Option<Vec<Diger>>, KERIError>
pub fn fetch_prior_digers( &self, sn: Option<u64>, ) -> Result<Option<Vec<Diger>>, KERIError>
Returns either the most recent prior list of digers before .last_est or None
Starts searching at sn or if sn is None at sn = .last_est.s - 1
Returns list of Digers instances at the most recent prior est event relative to the given sequence number (sn) otherwise returns None. Walks backwards to the more recent prior establishment event before the .sn if any. If sn represents an interaction event (ixn) then the result will be the current valid list of digers. If sn represents an establishment event then the result will be the list of digers immediately prior to the current list.
§Arguments
sn- Optional sequence number to start searching. If None then start at .last_est.s - 1
§Returns
Result<Option<Vec<Diger>>, KERIError>- Vector of Diger instances or None if no prior est evt to current .last_est