Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pipeline/forkhandler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pipeline

import (
"slices"
"sync"

pbssinternal "github.com/streamingfast/substreams/pb/sf/substreams/intern/v2"
Expand Down Expand Up @@ -42,8 +43,8 @@ func (f *ForkHandler) joinReversibleOutputs(target *pbsubstreams.Clock, previous
defer f.mu.Unlock()

reversibleOutputs := f.reversibleOutputs[target.Id]
for i := len(previousClocks) - 1; i >= 0; i-- {
if clock := previousClocks[i]; clock != nil {
for _, v := range slices.Backward(previousClocks) {
if clock := v; clock != nil {
if outputs, found := f.reversibleOutputs[clock.Id]; found {
reversibleOutputs = append(reversibleOutputs, outputs...)
delete(f.reversibleOutputs, clock.Id)
Expand Down
4 changes: 2 additions & 2 deletions pipeline/process_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"runtime/debug"
"slices"
"strconv"

"connectrpc.com/connect"
Expand Down Expand Up @@ -234,8 +235,7 @@ func (p *Pipeline) undoPartialStates() error {
return nil
}

for i := len(p.partialProcessingState.processedPartials) - 1; i >= 0; i-- {
clk := p.partialProcessingState.processedPartials[i]
for _, clk := range slices.Backward(p.partialProcessingState.processedPartials) {
if err := p.forkHandler.handleUndo(clk); err != nil {
return fmt.Errorf("reverting outputs: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/store/delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"errors"
"fmt"
"slices"
"strings"

pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
Expand Down Expand Up @@ -92,8 +93,7 @@ func storeTooBigError(storeName string, size, limit uint64) error {
func (b *baseStore) ApplyDeltasReverse(deltas []*pbsubstreams.StoreDelta) {
b.recentlyDeletedPrefixes.Clear() // whenever we have an undo block, we clear this cache to avoid any bug

for i := len(deltas) - 1; i >= 0; i-- {
delta := deltas[i]
for _, delta := range slices.Backward(deltas) {

newSize := uint64(len(delta.NewValue))
oldSize := uint64(len(delta.OldValue))
Expand Down
13 changes: 5 additions & 8 deletions storage/store/value_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"bytes"
"fmt"
"slices"

pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
)
Expand Down Expand Up @@ -63,8 +64,7 @@ func (b *baseStore) HasFirst(key string) bool {
}

func (b *baseStore) getLast(key string) ([]byte, bool) {
for i := len(b.deltas) - 1; i >= 0; i-- {
delta := b.deltas[i]
for _, delta := range slices.Backward(b.deltas) {
if delta.Key != key {
continue
}
Expand Down Expand Up @@ -96,8 +96,7 @@ func (b *baseStore) GetLast(key string) ([]byte, bool) {
}

func (b *baseStore) HasLast(key string) bool {
for i := len(b.deltas) - 1; i >= 0; i-- {
delta := b.deltas[i]
for _, delta := range slices.Backward(b.deltas) {
if delta.Key != key {
continue
}
Expand All @@ -119,8 +118,7 @@ func (b *baseStore) HasLast(key string) bool {
func (b *baseStore) getAt(ord uint64, key string) (out []byte, found bool) {
out, found = b.getLast(key)

for i := len(b.deltas) - 1; i >= 0; i-- {
delta := b.deltas[i]
for _, delta := range slices.Backward(b.deltas) {
if delta.Ordinal <= ord {
break
}
Expand Down Expand Up @@ -161,8 +159,7 @@ func (b *baseStore) GetAt(ord uint64, key string) (out []byte, found bool) {
func (b *baseStore) HasAt(ord uint64, key string) bool {
_, found := b.GetFirst(key)

for i := len(b.deltas) - 1; i >= 0; i-- {
delta := b.deltas[i]
for _, delta := range slices.Backward(b.deltas) {
if delta.Ordinal <= ord {
break
}
Expand Down
6 changes: 2 additions & 4 deletions tui2/pages/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ func (o *Output) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
o.statusBar.SetBytesRepresentation(o.bytesRepresentation)
o.setOutputViewContent(true)
case "N":
for i := len(o.searchMatchingOutputViewOffsets) - 1; i >= 0; i-- {
pos := o.searchMatchingOutputViewOffsets[i]
for _, pos := range slices.Backward(o.searchMatchingOutputViewOffsets) {
if pos < o.outputView.YOffset {
o.outputView.YOffset = pos
break
Expand Down Expand Up @@ -554,8 +553,7 @@ func (o *Output) jumpToPreviousMatchingBlock() tea.Cmd {
activeBlock := o.active.BlockNum
blocks := o.searchBlockNumsWithMatches
return func() tea.Msg {
for i := len(blocks) - 1; i >= 0; i-- {
block := blocks[i]
for _, block := range slices.Backward(blocks) {
if block < activeBlock {
return blockselect.BlockChangedMsg(block)
}
Expand Down