Commit 9f4504d
authored
poll new blocks in the committer when in live mode (#226)
### TL;DR
Added support for real-time block committing in addition to backfill mode.
### What changed?
- Added a new `getBlockToCommitUntil` function that determines the end block for committing based on work mode
- In real-time mode, the committer now checks the latest block from RPC and uses that as the upper bound if it's less than the calculated end block
- Created a `fetchBlockDataToCommit` function that handles different data retrieval strategies based on work mode:
- In backfill mode: retrieves data from staging storage
- In real-time mode: uses a `BoundlessPoller` to fetch data directly without saving to staging first
- Updated the `getBlockNumbersToCommit` function to accept a context parameter
- Refactored `getSequentialBlockDataToCommit` to use the new functions
### How to test?
1. Run the application in real-time mode and verify it correctly commits blocks up to the latest block from RPC
2. Run the application in backfill mode and verify it commits blocks in batches of `blocksPerCommit`
3. Verify that when switching between modes, the committer correctly adjusts its behavior
### Why make this change?
This change enables the committer to operate in two distinct modes:
1. Backfill mode: for historical data processing where blocks are first staged then committed
2. Real-time mode: for processing current blocks directly from the RPC without staging
This dual-mode approach improves efficiency by allowing real-time processing to skip the staging step when immediate data is needed, while maintaining the ability to process historical data in batches.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Improved block data fetching logic to dynamically adjust commit ranges based on current mode and blockchain state.
- **Bug Fixes**
- Updated gap handling to skip unnecessary operations in live mode, reducing redundant processing.
- **Tests**
- Enhanced test coverage to reflect new context-based method signatures and work mode handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->2 files changed
+80
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
140 | 143 | | |
141 | 144 | | |
142 | 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 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
143 | 190 | | |
144 | | - | |
| 191 | + | |
145 | 192 | | |
146 | 193 | | |
147 | 194 | | |
148 | 195 | | |
149 | 196 | | |
150 | 197 | | |
151 | 198 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 199 | + | |
157 | 200 | | |
158 | | - | |
| 201 | + | |
159 | 202 | | |
160 | 203 | | |
161 | | - | |
162 | | - | |
163 | 204 | | |
164 | 205 | | |
165 | 206 | | |
| |||
250 | 291 | | |
251 | 292 | | |
252 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
253 | 299 | | |
254 | 300 | | |
255 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | | - | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
96 | 100 | | |
97 | | - | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
146 | | - | |
| 152 | + | |
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
| |||
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
170 | 177 | | |
171 | 178 | | |
172 | | - | |
| 179 | + | |
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
| |||
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
| 200 | + | |
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
198 | | - | |
| 206 | + | |
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| |||
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| 225 | + | |
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
221 | 230 | | |
222 | | - | |
| 231 | + | |
223 | 232 | | |
224 | 233 | | |
225 | 234 | | |
| |||
239 | 248 | | |
240 | 249 | | |
241 | 250 | | |
| 251 | + | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
| |||
273 | 283 | | |
274 | 284 | | |
275 | 285 | | |
| 286 | + | |
276 | 287 | | |
277 | 288 | | |
278 | 289 | | |
| |||
311 | 322 | | |
312 | 323 | | |
313 | 324 | | |
| 325 | + | |
314 | 326 | | |
315 | 327 | | |
316 | 328 | | |
| |||
336 | 348 | | |
337 | 349 | | |
338 | 350 | | |
| 351 | + | |
339 | 352 | | |
340 | 353 | | |
341 | 354 | | |
| |||
459 | 472 | | |
460 | 473 | | |
461 | 474 | | |
| 475 | + | |
462 | 476 | | |
463 | 477 | | |
464 | 478 | | |
| |||
505 | 519 | | |
506 | 520 | | |
507 | 521 | | |
| 522 | + | |
508 | 523 | | |
509 | 524 | | |
510 | 525 | | |
| |||
0 commit comments