This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Yzang/debug iterator #89
Open
yzang2019
wants to merge
17
commits into
main
Choose a base branch
from
yzang/debug-iterator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cf96ed9
Add log for creating reverse iterator
yzang2019 4005b00
Add test iterator
yzang2019 1a1c0fb
Add cmd
yzang2019 c7bcf82
Fix start end
yzang2019 6ac285b
Print out all
yzang2019 50dbd29
Add log
yzang2019 90aec4e
Check error
yzang2019 0dade24
remove forward
yzang2019 a7b84c0
Add iterator key / version logging
Kbhat1 6dc11f8
Merge branch 'yzang/debug-iterator' of https://github.com/sei-protoco…
Kbhat1 3359d03
Merge branch 'main' into yzang/debug-iterator
Kbhat1 bb21bfa
Set upperbound to version+1
yzang2019 bad65c7
Try iter.prev
yzang2019 ea7aea1
Seek to end first
yzang2019 f87804a
Seek to end first
yzang2019 312eef8
key hex
yzang2019 c322777
log
yzang2019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package operations | ||
|
|
||
| import ( | ||
| "encoding/hex" | ||
| "fmt" | ||
|
|
||
| "github.com/sei-protocol/sei-db/common/logger" | ||
| "github.com/sei-protocol/sei-db/config" | ||
| "github.com/sei-protocol/sei-db/ss" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func TestIteratorCmd() *cobra.Command { | ||
| iteratorCmd := &cobra.Command{ | ||
| Use: "test-iterator", | ||
| Short: "Test forward or reverse iterator", | ||
| Run: executeIterator, | ||
| } | ||
|
|
||
| iteratorCmd.PersistentFlags().StringP("home-dir", "d", "/root/.sei", "Database Directory") | ||
| iteratorCmd.PersistentFlags().StringP("start", "s", "07", "Start key") | ||
| iteratorCmd.PersistentFlags().StringP("end", "e", "08", "End key") | ||
|
|
||
| return iteratorCmd | ||
| } | ||
|
|
||
| func executeIterator(cmd *cobra.Command, _ []string) { | ||
| homeDir, _ := cmd.Flags().GetString("home-dir") | ||
| start, _ := cmd.Flags().GetString("start") | ||
| end, _ := cmd.Flags().GetString("end") | ||
| IterateDbData(homeDir, start, end) | ||
| } | ||
|
|
||
| func IterateDbData(homeDir string, start string, end string) { | ||
| ssConfig := config.DefaultStateStoreConfig() | ||
| ssConfig.KeepRecent = 0 | ||
| ssStore, err := ss.NewStateStore(logger.NewNopLogger(), homeDir, ssConfig) | ||
| defer ssStore.Close() | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| fmt.Printf("Start forward iteration\n") | ||
| forwardIter, err := ssStore.Iterator("oracle", 98350313, nil, nil) | ||
| for ; forwardIter.Valid(); forwardIter.Next() { | ||
| fmt.Printf("key: %X, value %X\n", forwardIter.Key(), forwardIter.Value()) | ||
| } | ||
| forwardIter.Close() | ||
| fmt.Printf("Finished forward iteration\n") | ||
| fmt.Printf("Start reverse iteration\n") | ||
| startPos, _ := hex.DecodeString(start) | ||
| endPos, _ := hex.DecodeString(end) | ||
| iter, err := ssStore.ReverseIterator("oracle", 98350313, startPos, endPos) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| for ; iter.Valid(); iter.Next() { | ||
| fmt.Printf("key: %X, value %X\n", iter.Key(), iter.Value()) | ||
| } | ||
| iter.Close() | ||
| fmt.Printf("Complete reverse iteration\n") | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.