Skip to content

Commit

Permalink
added start and stop block
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Nov 2, 2023
1 parent e59fbad commit eb663bc
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cmd/honey-tracker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"os"

"github.com/streamingfast/bstream"

"github.com/spf13/cobra"
"github.com/streamingfast/cli/sflags"

Expand Down Expand Up @@ -33,6 +35,8 @@ func init() {
RootCmd.Flags().String("db-user", "user", "PostgreSQL user")
RootCmd.Flags().String("db-password", "secureme", "PostgreSQL password")
RootCmd.Flags().String("db-name", "postgres", "PostgreSQL database name")
RootCmd.Flags().Uint64("start-block", 0, "start block number (0 means no start block)")
RootCmd.Flags().Uint64("stop-block", 0, "stop block number (0 means no stop block)")

// Manifest
RootCmd.Flags().String("output-module-type", "proto:hivemapper.types.v1.Output", "Expected output module type")
Expand All @@ -53,6 +57,8 @@ func rootRun(cmd *cobra.Command, args []string) error {

flagInsecure := sflags.MustGetBool(cmd, "insecure")
flagPlaintext := sflags.MustGetBool(cmd, "plaintext")
startBlock := sflags.MustGetUint64(cmd, "start-block")
stopBlock := sflags.MustGetUint64(cmd, "start-block")

db := data.NewPostgreSQL(
&data.PsqlInfo{
Expand All @@ -77,6 +83,20 @@ func rootRun(cmd *cobra.Command, args []string) error {
pkg, module, outputModuleHash, br, err := sink.ReadManifestAndModuleAndBlockRange(manifestPath, nil, outputModuleName, expectedOutputModuleType, false, "", logger)
checkError(err)

options := []sink.Option{
sink.WithBlockRange(br),
sink.WithAverageBlockSec("average received block second", 30),
sink.WithAverageBlockTimeProcessing("average block processing time", 1000),
}

if startBlock > 0 && stopBlock > 0 {
blockRange, err := bstream.NewRangeContaining(startBlock, stopBlock)
if err != nil {
return fmt.Errorf("creating block range: %w", err)
}
options = append(options, sink.WithBlockRange(blockRange))
}

s, err := sink.New(
sink.SubstreamsModeProduction,
pkg,
Expand All @@ -85,9 +105,7 @@ func rootRun(cmd *cobra.Command, args []string) error {
clientConfig,
logger,
tracer,
sink.WithBlockRange(br),
sink.WithAverageBlockSec("average received block second", 30),
sink.WithAverageBlockTimeProcessing("average block processing time", 1000),
options...,
)
checkError(err)

Expand Down

0 comments on commit eb663bc

Please sign in to comment.