From 62f57f2ba71951cf15434a709c7feba616b8202f Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Fri, 19 May 2023 15:36:56 -0400 Subject: [PATCH] Fixed wrong writing of cursor leading to invalid cursor being written --- CHANGELOG.md | 6 ++++++ db/cursor.go | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d66cfe..8872896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/db/cursor.go b/db/cursor.go index 26604cc..22a0f61 100644 --- a/db/cursor.go +++ b/db/cursor.go @@ -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") @@ -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) } @@ -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) }