Skip to content

Commit

Permalink
Ported all remaining tools to firehose-core framework
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh committed Oct 27, 2023
1 parent 76f50ca commit f66c79d
Show file tree
Hide file tree
Showing 18 changed files with 901 additions and 850 deletions.
3 changes: 2 additions & 1 deletion cmd/fireeth/cli/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/streamingfast/bstream"
"github.com/streamingfast/bstream/blockstream"
"github.com/streamingfast/dlauncher/launcher"
firecore "github.com/streamingfast/firehose-core"
"github.com/streamingfast/firehose-ethereum/codec"
nodemanager "github.com/streamingfast/firehose-ethereum/node-manager"
"github.com/streamingfast/firehose-ethereum/node-manager/dev"
Expand Down Expand Up @@ -203,7 +204,7 @@ func nodeFactoryFunc(isReader bool, backupModuleFactories map[string]operator.Ba
oneBlocksStoreURL,
workingDir,
func(lines chan string) (reader.ConsolerReader, error) {
return codec.NewConsoleReader(appLogger, lines)
return codec.NewConsoleReader(lines, firecore.NewBlockEncoder(), appLogger, appTracer)
},
batchStartBlockNum,
batchStopBlockNum,
Expand Down
3 changes: 2 additions & 1 deletion cmd/fireeth/cli/reader-node-stdin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/streamingfast/dlauncher/launcher"
firecore "github.com/streamingfast/firehose-core"
"github.com/streamingfast/firehose-ethereum/codec"
"github.com/streamingfast/logging"
nodeManager "github.com/streamingfast/node-manager"
Expand All @@ -41,7 +42,7 @@ func init() {
archiveStoreURL := MustReplaceDataDir(sfDataDir, viper.GetString("common-one-block-store-url"))

consoleReaderFactory := func(lines chan string) (mindreader.ConsolerReader, error) {
r, err := codec.NewConsoleReader(appLogger, lines)
r, err := codec.NewConsoleReader(lines, firecore.NewBlockEncoder(), appLogger, appTracer)
if err != nil {
return nil, fmt.Errorf("initiating console reader: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/fireeth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ var Chain = &firecore.Chain[*pbeth.Block]{
BlockPrinter: printBlock,

RegisterExtraCmd: func(chain *firecore.Chain[*pbeth.Block], toolsCmd *cobra.Command, zlog *zap.Logger, tracer logging.Tracer) error {
// toolsCmd.AddCommand(newToolsGenerateNodeKeyCmd(chain))
// toolsCmd.AddCommand(newToolsBackfillCmd(zlog))
toolsCmd.AddCommand(compareOneblockRPCCmd)
toolsCmd.AddCommand(newCompareBlocksRPCCmd(zlog))
toolsCmd.AddCommand(newFixPolygonIndexCmd(zlog))
toolsCmd.AddCommand(newPollRPCBlocksCmd(zlog))

return nil
},
Expand Down
6 changes: 4 additions & 2 deletions cmd/fireeth/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/streamingfast/bstream"
firecore "github.com/streamingfast/firehose-core"
pbeth "github.com/streamingfast/firehose-ethereum/types/pb/sf/ethereum/type/v2"
"github.com/test-go/testify/require"
)
Expand All @@ -13,10 +14,11 @@ func Test_Encode_Decode_Block(t *testing.T) {
Chain.Validate()
Chain.Init()

original, err := Chain.BlockEncoder.Encode(&pbeth.Block{
original, err := Chain.BlockEncoder.Encode(firecore.BlockEnveloppe{Block: &pbeth.Block{
Number: 1,
Header: &pbeth.BlockHeader{},
})
Ver: 1,
}, LIBNum: 0})
require.NoError(t, err)

require.Equal(t, uint64(1), original.ToProtocol().(*pbeth.Block).Number)
Expand Down
5 changes: 5 additions & 0 deletions cmd/fireeth/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"

"github.com/streamingfast/bstream"
"github.com/streamingfast/cli"
pbeth "github.com/streamingfast/firehose-ethereum/types/pb/sf/ethereum/type/v2"
)

Expand All @@ -31,3 +32,7 @@ func printBlock(blk *bstream.Block, alsoPrintTransactions bool, out io.Writer) e

return nil
}

func ExamplePrefixed(prefix, examples string) string {
return string(cli.ExamplePrefixed(prefix, examples))
}
Loading

0 comments on commit f66c79d

Please sign in to comment.