Understanding TAPLE’s event types and event-driven model
Events are the core mechanism for state changes in TAPLE. Every modification to a subject is represented as an immutable, signed event that forms part of the subject’s event chain.
An event contains all information about a state transition:
pub struct Event { /// The identifier of the subject of the event. pub subject_id: DigestIdentifier, /// The signed event request. pub event_request: Signed<EventRequest>, /// The sequence number of the event. pub sn: u64, /// The version of the governance contract. pub gov_version: u64, /// The patch to apply to the state. pub patch: ValueWrapper, /// The hash of the state after applying the patch. pub state_hash: DigestIdentifier, /// Whether the evaluation was successful and the result was validated against the schema. pub eval_success: bool, /// Whether approval is required for the event to be applied to the state. pub appr_required: bool, /// Whether the event has been approved. pub approved: bool, /// The hash of the previous event. pub hash_prev_event: DigestIdentifier, /// The set of evaluators who have evaluated the event. pub evaluators: HashSet<Signature>, /// The set of approvers who have approved the event. pub approvers: HashSet<Signature>,}
Source: commons/models/event.rs:26-51
Events are immutable once created and signed. They form a cryptographically-linked chain through the hash_prev_event field.
pub enum EventRequest { /// A request to create a new subject. Create(StartRequest), /// A request to add a fact to a subject. Fact(FactRequest), /// A request to transfer ownership of a subject. Transfer(TransferRequest), /// A request to mark a subject as end-of-life. EOL(EOLRequest),}
pub struct StartRequest { /// The identifier of the governance contract. pub governance_id: DigestIdentifier, /// The identifier of the schema used to validate the event. pub schema_id: String, /// The namespace of the subject. pub namespace: String, /// The name of the subject. pub name: String, /// The identifier of the public key of the subject owner. pub public_key: KeyIdentifier,}
pub struct FactRequest { /// The identifier of the subject to which the fact will be added. pub subject_id: DigestIdentifier, /// The payload of the fact to be added. pub payload: ValueWrapper,}
Source: commons/models/request.rs:43-49
Fact requests are the only type that require evaluation and approval according to governance policies.
pub struct TransferRequest { /// The identifier of the subject to transfer ownership of. pub subject_id: DigestIdentifier, /// The identifier of the public key of the new owner. pub public_key: KeyIdentifier,}
pub struct Metadata { /// The namespace of the event. pub namespace: String, /// The identifier of the subject of the event. pub subject_id: DigestIdentifier, /// The identifier of the governance contract. pub governance_id: DigestIdentifier, /// The version of the governance contract. pub governance_version: u64, /// The identifier of the schema used to validate the event. pub schema_id: String,}