coven_database/store/
publication_state.rs1use crate::{
2 DurablePreparedProtocolObject, PreparedAudienceObjects, StoreBatchCompletion,
3 StoreBatchLocalCleanup,
4};
5use coven_protocol::objects::PreparedProtocolObject;
6use coven_protocol::store_commit::{
7 StoreBatchCommitRef, StoreDeviceHead, StoreRootRef, VerifiedStoreBatchCommit,
8};
9use coven_protocol::write::WriteId;
10
11pub struct StoreWritePreparation {
12 pub root: StoreRootRef,
13 pub write_id: WriteId,
14 pub remote_objects: Vec<coven_protocol::remote_object::ClosedRemoteObject>,
15 pub audiences: PreparedAudienceObjects,
16 pub commit: PreparedProtocolObject<VerifiedStoreBatchCommit>,
17 pub head: PreparedProtocolObject<StoreDeviceHead>,
18 pub history_evidence: coven_protocol::store_commit::RetainedMergeCommitEvidence,
19 pub local_cleanup: StoreBatchLocalCleanup,
20 pub completion: StoreBatchCompletion,
21}
22
23pub struct MergeCandidateAbandonmentPreparation {
24 pub write_id: WriteId,
25 pub commit: PreparedProtocolObject<VerifiedStoreBatchCommit>,
26 pub head: PreparedProtocolObject<StoreDeviceHead>,
27 pub history_evidence: coven_protocol::store_commit::RetainedMergeCommitEvidence,
28}
29
30#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
31#[serde(rename_all = "snake_case", deny_unknown_fields)]
32pub enum PreparedStoreWriteState {
33 Publication {
34 commit: DurablePreparedProtocolObject,
35 head: DurablePreparedProtocolObject,
36 history_evidence: coven_protocol::store_commit::RetainedMergeCommitEvidence,
37 local_cleanup: StoreBatchLocalCleanup,
38 completion: StoreBatchCompletion,
39 },
40 MergeAbandonment {
41 candidate_commit: DurablePreparedProtocolObject,
42 candidate_head: DurablePreparedProtocolObject,
43 candidate_history_evidence: coven_protocol::store_commit::RetainedMergeCommitEvidence,
44 authority_commit: DurablePreparedProtocolObject,
45 authority_head: DurablePreparedProtocolObject,
46 authority_history_evidence: coven_protocol::store_commit::RetainedMergeCommitEvidence,
47 outcome: MergeAbandonmentOutcome,
48 local_cleanup: StoreBatchLocalCleanup,
49 completion: StoreBatchCompletion,
50 },
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
54#[serde(rename_all = "snake_case", deny_unknown_fields)]
55pub enum MergeAbandonmentOutcome {
56 Prepared,
57 Accepted {
58 authority: StoreBatchCommitRef,
59 },
60 Lost {
61 winner_commit: StoreBatchCommitRef,
62 winner_head: coven_protocol::store_commit::StoreDeviceHeadRef,
63 },
64 AuthorExcluded,
65}