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
use crate::ledger_counters::LedgerCounterBumps;
use diem_types::transaction::Version;
use schemadb::SchemaBatch;
use std::collections::HashMap;
pub(crate) struct ChangeSet {
pub batch: SchemaBatch,
counter_bumps: HashMap<Version, LedgerCounterBumps>,
}
impl ChangeSet {
pub fn new() -> Self {
Self {
batch: SchemaBatch::new(),
counter_bumps: HashMap::new(),
}
}
pub fn counter_bumps(&mut self, version: Version) -> &mut LedgerCounterBumps {
self.counter_bumps
.entry(version)
.or_insert_with(LedgerCounterBumps::new)
}
#[cfg(test)]
pub fn new_with_bumps(counter_bumps: HashMap<Version, LedgerCounterBumps>) -> Self {
Self {
batch: SchemaBatch::new(),
counter_bumps,
}
}
}
pub(crate) struct SealedChangeSet {
pub batch: SchemaBatch,
}