Skip to content

Commit

Permalink
Fixed wrong writing of cursor leading to invalid cursor being written
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed May 19, 2023
1 parent d55c5c8 commit 62f57f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v2.1.3

### Fixed

* Fixed wrong writing of cursor leading to invalid cursor being written.

## v2.1.2

### Changed
Expand Down
6 changes: 5 additions & 1 deletion db/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/streamingfast/kvdb/store"
sink "github.com/streamingfast/substreams-sink"
"go.uber.org/zap"
)

var ErrCursorNotFound = errors.New("cursor not found")
Expand All @@ -22,6 +23,9 @@ func (l *DB) GetCursor(ctx context.Context) (*sink.Cursor, error) {
}
return nil, err
}

l.logger.Debug("cursor found", zap.String("cursor", string(val)))

return cursorFromBytes(val)
}

Expand All @@ -34,7 +38,7 @@ func (l *DB) WriteCursor(ctx context.Context, c *sink.Cursor) error {
}

func cursorToBytes(c *sink.Cursor) []byte {
out := fmt.Sprintf("%s:%s:%d", c.Cursor, c.Block().ID(), c.Block().Num())
out := fmt.Sprintf("%s:%s:%d", c.String(), c.Block().ID(), c.Block().Num())
return []byte(out)
}

Expand Down

0 comments on commit 62f57f2

Please sign in to comment.