Skip to content

Commit

Permalink
Improved usability
Browse files Browse the repository at this point in the history
* Made argument `<manifest>` optional again, in which case `.` is assumed.
* Added ability to provide `<manifest>` argument as a directory, enabling the possibility to do `substreams-sink-kv inject <endpoint> <dsn> .`
  • Loading branch information
maoueh committed May 17, 2023
1 parent e91ec43 commit aa861ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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.1

### Added

* Made argument `<manifest>` optional again, in which case `.` is assumed.

* Added ability to provide `<manifest>` argument as a directory, enabling the possibility to do `substreams-sink-kv inject <endpoint> <dsn> .`

## v2.1.0

### Highlights
Expand Down
17 changes: 13 additions & 4 deletions cmd/substreams-sink-kv/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
)

var injectCmd = Command(injectRunE,
"inject <endpoint> <dsn> <manifest> [<start>:<stop>]",
"inject <endpoint> <dsn> [<manifest>] [<start>:<stop>]",
"Fills a KV store from a Substreams output and optionally runs a server",
RangeArgs(3, 4),
RangeArgs(2, 4),
Flags(func(flags *pflag.FlagSet) {
sink.AddFlagsToSet(flags)

Expand All @@ -35,14 +35,20 @@ var injectCmd = Command(injectRunE,
The required arguments are:
- <endpoint>: The Substreams endpoint to reach (e.g. 'mainnet.eth.streamingfast.io:443').
- <dsn>: URL to connect to the KV store, see https://github.com/streamingfast/kvdb for more DSN details (e.g. 'badger3:///tmp/substreams-sink-kv-db').
- <manifest>: URL or local path to a '.spkg' file (e.g. 'https://github.com/streamingfast/substreams-eth-block-meta/releases/download/v0.4.0/substreams-eth-block-meta-v0.4.0.spkg').
The optional arguments are:
- <manifest>: URL or local path to a '.spkg' file (e.g. 'https://github.com/streamingfast/substreams-eth-block-meta/releases/download/v0.4.0/substreams-eth-block-meta-v0.4.0.spkg').
- <start>:<stop>: The range of block to sync, if not provided, will sync from the module's initial block and then forever.
Note that if you need to provide a block range, <manifest> needs to be provided. Use '.'
which is the default when <manifest> is not provided.
`),
ExamplePrefixed("substreams-sink-kv inject", `
# Inject key/values produced by kv_out for the whole chain
mainnet.eth.streamingfast.io:443 badger3:///tmp/block-meta-db https://github.com/streamingfast/substreams-eth-block-meta/releases/download/v0.4.0/substreams-eth-block-meta-v0.4.0.spkg
# Inject key/values produced by Substreams in curret directory for range 10 000 to 20 000
mainnet.eth.streamingfast.io:443 badger3:///tmp/block-meta-db . 10_000:20_000
`),
OnCommandErrorLogAndExit(zlog),
)
Expand Down Expand Up @@ -151,7 +157,10 @@ func injectRunE(cmd *cobra.Command, args []string) error {
func extractInjectArgs(_ *cobra.Command, args []string) (endpoint, dsn, manifestPath, blockRange string) {
endpoint = args[0]
dsn = args[1]
manifestPath = args[2]
if len(args) >= 3 {
manifestPath = args[2]
}

if len(args) == 4 {
blockRange = args[3]
}
Expand Down

0 comments on commit aa861ae

Please sign in to comment.