1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::ops::RangeBounds;
use std::sync::Arc;
use std::vec::Vec;
use crate::block;
use crate::operation;
use crate::operation::{GroupId, OperationId};
pub mod error;
pub use error::Error;
#[cfg(feature = "memory-pending")]
pub mod memory;
pub trait PendingStore: Send + Sync + 'static {
fn put_operation(&mut self, operation: operation::NewOperation) -> Result<bool, Error>;
fn update_operation_commit_status(
&mut self,
operation_id: OperationId,
status: CommitStatus,
) -> Result<(), Error>;
fn get_operation(&self, operation_id: OperationId) -> Result<Option<StoredOperation>, Error>;
fn get_group_operations(
&self,
group_id: GroupId,
) -> Result<Option<StoredOperationsGroup>, Error>;
fn operations_iter<R>(&self, range: R) -> Result<TimelineIterator, Error>
where
R: RangeBounds<OperationId>;
fn operations_count(&self) -> usize;
fn delete_operation(&mut self, operation_id: OperationId) -> Result<(), Error>;
}
pub type TimelineIterator<'store> = Box<dyn Iterator<Item = StoredOperation> + 'store>;
#[derive(Clone)]
pub struct StoredOperation {
pub group_id: GroupId,
pub operation_id: OperationId,
pub operation_type: operation::OperationType,
pub commit_status: CommitStatus,
pub frame: Arc<operation::OperationFrame<Vec<u8>>>,
}
pub struct StoredOperationsGroup {
pub group_id: GroupId,
pub operations: Vec<StoredOperation>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommitStatus {
Unknown,
Committed(block::BlockOffset, block::BlockHeight),
}