Skip to content

Commit d6597c9

Browse files
authored
Fix flashblocks index (#36)
* Use different approach * fmt
1 parent 3560553 commit d6597c9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/publish.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ impl Step<Flashblocks> for PublishFlashblock {
120120
.expect("withdrawals_root is present"),
121121
};
122122

123+
// Get 0-index to use in flashblock
124+
let index = self.flashblock_number.index();
123125
// Increment flashblock number since we've built the flashblock
124-
let index = self.flashblock_number.advance();
126+
self.flashblock_number.advance();
125127

126128
// Push the contents of the payload
127129
if let Err(e) = self.sink.publish(&FlashblocksPayloadV1 {

src/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ impl FlashblockNumber {
2727
self.target_flashblocks.load(Ordering::Relaxed)
2828
}
2929

30+
/// Returns current flashblock in 0-index format
31+
pub fn index(&self) -> u64 {
32+
self
33+
.current_flashblock
34+
.load(Ordering::Relaxed)
35+
.saturating_sub(1)
36+
}
37+
3038
pub fn advance(&self) -> u64 {
3139
self.current_flashblock.fetch_add(1, Ordering::Relaxed)
3240
}

0 commit comments

Comments
 (0)