rm redundant node info
This commit is contained in:
parent
f528cfdf71
commit
1f477f24ea
@ -50,8 +50,7 @@ func NewStateDiffIndexer(
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, fmt.Errorf("file config is not the correct type: got %T, expected %T", config, file.Config{})
|
return nil, nil, fmt.Errorf("file config is not the correct type: got %T, expected %T", config, file.Config{})
|
||||||
}
|
}
|
||||||
fc.NodeInfo = nodeInfo
|
ind, err := file.NewStateDiffIndexer(chainConfig, fc, nodeInfo)
|
||||||
ind, err := file.NewStateDiffIndexer(chainConfig, fc)
|
|
||||||
return nil, ind, err
|
return nil, ind, err
|
||||||
case shared.POSTGRES:
|
case shared.POSTGRES:
|
||||||
log.Info("Starting statediff service in Postgres writing mode")
|
log.Info("Starting statediff service in Postgres writing mode")
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ type Config struct {
|
|||||||
OutputDir string
|
OutputDir string
|
||||||
FilePath string
|
FilePath string
|
||||||
WatchedAddressesFilePath string
|
WatchedAddressesFilePath string
|
||||||
NodeInfo node.Info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileMode to explicitly type the mode of file writer we are using
|
// FileMode to explicitly type the mode of file writer we are using
|
||||||
@ -70,20 +68,11 @@ func (c Config) Type() shared.DBType {
|
|||||||
return shared.FILE
|
return shared.FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
var nodeInfo = node.Info{
|
|
||||||
GenesisBlock: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
|
||||||
NetworkID: "1",
|
|
||||||
ChainID: 1,
|
|
||||||
ID: "mockNodeID",
|
|
||||||
ClientName: "go-ethereum",
|
|
||||||
}
|
|
||||||
|
|
||||||
// CSVTestConfig config for unit tests
|
// CSVTestConfig config for unit tests
|
||||||
var CSVTestConfig = Config{
|
var CSVTestConfig = Config{
|
||||||
Mode: CSV,
|
Mode: CSV,
|
||||||
OutputDir: "./statediffing_test",
|
OutputDir: "./statediffing_test",
|
||||||
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.csv",
|
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.csv",
|
||||||
NodeInfo: nodeInfo,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SQLTestConfig config for unit tests
|
// SQLTestConfig config for unit tests
|
||||||
@ -91,5 +80,4 @@ var SQLTestConfig = Config{
|
|||||||
Mode: SQL,
|
Mode: SQL,
|
||||||
FilePath: "./statediffing_test_file.sql",
|
FilePath: "./statediffing_test_file.sql",
|
||||||
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.sql",
|
WatchedAddressesFilePath: "./statediffing_watched_addresses_test_file.sql",
|
||||||
NodeInfo: nodeInfo,
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func setupLegacyCSVIndexer(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ind, err = file.NewStateDiffIndexer(test.LegacyConfig, file.CSVTestConfig)
|
ind, err = file.NewStateDiffIndexer(test.LegacyConfig, file.CSVTestConfig, test.LegacyNodeInfo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db, err = postgres.SetupSQLXDB()
|
db, err = postgres.SetupSQLXDB()
|
||||||
|
@ -41,7 +41,7 @@ func setupCSVIndexer(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ind, err = file.NewStateDiffIndexer(mocks.TestChainConfig, file.CSVTestConfig)
|
ind, err = file.NewStateDiffIndexer(mocks.TestChainConfig, file.CSVTestConfig, test.LegacyNodeInfo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db, err = postgres.SetupSQLXDB()
|
db, err = postgres.SetupSQLXDB()
|
||||||
|
@ -38,6 +38,7 @@ import (
|
|||||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
||||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||||
"github.com/cerc-io/plugeth-statediff/utils/log"
|
"github.com/cerc-io/plugeth-statediff/utils/log"
|
||||||
@ -62,7 +63,7 @@ type StateDiffIndexer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStateDiffIndexer creates a void implementation of interfaces.StateDiffIndexer
|
// NewStateDiffIndexer creates a void implementation of interfaces.StateDiffIndexer
|
||||||
func NewStateDiffIndexer(chainConfig *params.ChainConfig, config Config) (*StateDiffIndexer, error) {
|
func NewStateDiffIndexer(chainConfig *params.ChainConfig, config Config, nodeInfo node.Info) (*StateDiffIndexer, error) {
|
||||||
var err error
|
var err error
|
||||||
var writer FileWriter
|
var writer FileWriter
|
||||||
|
|
||||||
@ -115,12 +116,12 @@ func NewStateDiffIndexer(chainConfig *params.ChainConfig, config Config) (*State
|
|||||||
|
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
writer.Loop()
|
writer.Loop()
|
||||||
writer.upsertNode(config.NodeInfo)
|
writer.upsertNode(nodeInfo)
|
||||||
|
|
||||||
return &StateDiffIndexer{
|
return &StateDiffIndexer{
|
||||||
fileWriter: writer,
|
fileWriter: writer,
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
nodeID: config.NodeInfo.ID,
|
nodeID: nodeInfo.ID,
|
||||||
wg: wg,
|
wg: wg,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func setupMainnetIndexer(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ind, err = file.NewStateDiffIndexer(chainConf, file.CSVTestConfig)
|
ind, err = file.NewStateDiffIndexer(chainConf, file.CSVTestConfig, test.LegacyNodeInfo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db, err = postgres.SetupSQLXDB()
|
db, err = postgres.SetupSQLXDB()
|
||||||
|
@ -44,7 +44,7 @@ func setupLegacySQLIndexer(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ind, err = file.NewStateDiffIndexer(test.LegacyConfig, file.SQLTestConfig)
|
ind, err = file.NewStateDiffIndexer(test.LegacyConfig, file.SQLTestConfig, test.LegacyNodeInfo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db, err = postgres.SetupSQLXDB()
|
db, err = postgres.SetupSQLXDB()
|
||||||
|
@ -41,7 +41,7 @@ func setupIndexer(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ind, err = file.NewStateDiffIndexer(mocks.TestChainConfig, file.SQLTestConfig)
|
ind, err = file.NewStateDiffIndexer(mocks.TestChainConfig, file.SQLTestConfig, test.LegacyNodeInfo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
db, err = postgres.SetupSQLXDB()
|
db, err = postgres.SetupSQLXDB()
|
||||||
|
@ -44,10 +44,6 @@ type Config struct {
|
|||||||
ConnTimeout time.Duration
|
ConnTimeout time.Duration
|
||||||
LogStatements bool
|
LogStatements bool
|
||||||
|
|
||||||
// node info params
|
|
||||||
ID string
|
|
||||||
ClientName string
|
|
||||||
|
|
||||||
// driver type
|
// driver type
|
||||||
Driver DriverType
|
Driver DriverType
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/mocks"
|
"github.com/cerc-io/plugeth-statediff/indexer/mocks"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -36,6 +37,14 @@ var (
|
|||||||
legacyData = mocks.NewLegacyData(LegacyConfig)
|
legacyData = mocks.NewLegacyData(LegacyConfig)
|
||||||
mockLegacyBlock *types.Block
|
mockLegacyBlock *types.Block
|
||||||
legacyHeaderCID cid.Cid
|
legacyHeaderCID cid.Cid
|
||||||
|
// Mainnet node info
|
||||||
|
LegacyNodeInfo = node.Info{
|
||||||
|
GenesisBlock: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
|
||||||
|
NetworkID: "1",
|
||||||
|
ChainID: 1,
|
||||||
|
ID: "mockNodeID",
|
||||||
|
ClientName: "go-ethereum",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupLegacyTestData(t *testing.T, ind interfaces.StateDiffIndexer) {
|
func SetupLegacyTestData(t *testing.T, ind interfaces.StateDiffIndexer) {
|
||||||
|
@ -173,8 +173,6 @@ func initConfig() {
|
|||||||
case shared.FILE:
|
case shared.FILE:
|
||||||
indexerConfig = fileConfig
|
indexerConfig = fileConfig
|
||||||
case shared.POSTGRES:
|
case shared.POSTGRES:
|
||||||
dbConfig.ID = config.ID
|
|
||||||
dbConfig.ClientName = config.ClientName
|
|
||||||
indexerConfig = dbConfig
|
indexerConfig = dbConfig
|
||||||
case shared.DUMP:
|
case shared.DUMP:
|
||||||
switch dbDumpDst {
|
switch dbDumpDst {
|
||||||
|
Loading…
Reference in New Issue
Block a user