Commit a8a1257
authored
refactor: storage segments cleanup (#244)
* segments cache struct and evict method generalized
* save segments to disk made generic inside the segments cache struct
* save_dirty_segments logic refactorized
* tbh I dont know waht I refactored here
* removed io module inside storage/disk
* you are right rabbit
* store in segment moved to SegmentCache
* sentinel headers creation moved to the Persistable trait and encapsulated there
* unified sentinel item behaviour - no longer compiles bcs the tip_high calculation
* renames
* new struct to manage the hashmap of segments and tip height moved - doesnt compile yet, wip
* get_headers generalized in the SegmentsCache struct - wip, not compiles
* store headers logic moved to the SegmentsCache and introduced method to better handle tip_height and storage index - wip, no compiles
* store_headers_impl using precomputed_hashes didn't provide real benefics with the current usage - wip, no compiles
* removed unused StorageManager::get_headers_batch methos - wip, no compiles
* removed warnings
* ensure segment loaded moved inside the SegmentsCache with a logic change, we ask for a segment and if it doesn't exist in memory we load it from disk - wip, no compiles
* const MAX_ACTIVE_SEGMENTS encapsulated - wip, no compiles
* removed one commit as it is fixed
* created a SegmentsCache::store_headers_at_height - wip, no compiles
* removed inconsistency when loading segments metadata
* removed to methods unused bcs now that behaviour is encapsulated
* building SegmentCache yip_height when creating the struct
* removed unused function
* some refactor and removed the notification enum and related behaviour - wip, no compiles
* disk storage manager worker no longer needs cloned headers to work
* renamed segments stoage fields
* removed new unused function
* evict logic removed
* save dirty segments logic moved into SegmentsCache
* clippy warnings fixed
* save dirty is now an instance method for the DiskStorageManager
* when persisting segments we try to create the parent dirs to ensure they exist
* improved logic to ensure different clear behaviour for SegmentsCache
* correctly rebuilding the block reverse index
* fixed bug found by test test_checkpoint_storage_indexing
* fixed bug updating tip_height in SegmentCache thanks spotted by test test_filter_header_segments
* fixed bug, we stop persisting segments after we find the first sentinel, to correctly initialize valid_count - bug spotted by test test_filter_header_persistence
* refactor: HEADER_PER_SEGMENT encapsulated inside segment and renamed to ITEMS_PER_SEGMENT - wip, no compiles
* block index rebuild logic moved into SegmentCache<BlockHeader> and load_segment_metadata renamed in flavor of a better name for its current behaviour being the block index contructor
* added some cool inlines
* fixed test that was creating a centinel filter header at height 0 making the segment not persist entirely
* renamed header reference to item in segments.rs so its clear that the new struct can work with any struct
* clippy warning fixed
* logging when storing multiple items simplified
* removed sentinel headers from the segments logic
* unit tests for the segment and segment_cache structs after the refactor (#259)
* removed unused methods after rebase
* renamed and removed old documentation for store_headers_impl
* refactorized and adjusted docs for conversion methods between stoage index, height and offset
* removed old comments and forcing to give sync_base_height when creating the SegmentCache
* quick fix to load sync_base_height if persisted before
* review comments addressed
* read block index operation made async
* using atomic write where we write to disk1 parent 8f97c4b commit a8a1257
File tree
15 files changed
+863
-1410
lines changed- dash-spv
- src
- storage
- disk
- sync/headers
- tests
15 files changed
+863
-1410
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | 3 | | |
9 | 4 | | |
10 | 5 | | |
11 | 6 | | |
12 | | - | |
13 | 7 | | |
14 | 8 | | |
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 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 9 | | |
187 | 10 | | |
188 | 11 | | |
| |||
205 | 28 | | |
206 | 29 | | |
207 | 30 | | |
208 | | - | |
209 | | - | |
210 | | - | |
| 31 | + | |
| 32 | + | |
211 | 33 | | |
212 | | - | |
| 34 | + | |
213 | 35 | | |
214 | 36 | | |
215 | 37 | | |
| |||
0 commit comments