aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeng-Ying Yang <garfield@dexon.org>2019-01-09 15:21:41 +0800
committerWei-Ning Huang <w@dexon.org>2019-01-14 15:26:26 +0800
commit3bdc152de0b76e83df695091b859c4ecbcf14f60 (patch)
tree7e7c99dc3d44879f89d3949d935192e5f09b052c
parentddef70954ade739c2843f466525b24b6df40071b (diff)
downloaddexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar.gz
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar.bz2
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar.lz
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar.xz
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.tar.zst
dexon-3bdc152de0b76e83df695091b859c4ecbcf14f60.zip
indexer: pass network-related params through config (#133)
Pass following network related params: * Genesis block * Network ID And sync mode for indexer configuration.
-rw-r--r--cmd/utils/flags.go4
-rw-r--r--indexer/config.go10
2 files changed, 14 insertions, 0 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index f4005b8b3..fec073890 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -1303,6 +1303,10 @@ func setIndexerConfig(ctx *cli.Context, cfg *dex.Config) {
cfg.Indexer.Plugin = ctx.GlobalString(IndexerPluginFlag.Name)
cfg.Indexer.PluginFlags = ctx.GlobalString(IndexerPluginFlagsFlag.Name)
+ // copy required dex configs
+ cfg.Indexer.Genesis = cfg.Genesis
+ cfg.Indexer.NetworkID = cfg.NetworkId
+ cfg.Indexer.SyncMode = cfg.SyncMode
}
// SetDashboardConfig applies dashboard related command line flags to the config.
diff --git a/indexer/config.go b/indexer/config.go
index 396a23b66..0da9502a6 100644
--- a/indexer/config.go
+++ b/indexer/config.go
@@ -2,6 +2,9 @@ package indexer
import (
"plugin"
+
+ "github.com/dexon-foundation/dexon/core"
+ "github.com/dexon-foundation/dexon/dex/downloader"
)
// Config is data sources related configs struct.
@@ -14,6 +17,13 @@ type Config struct {
// PluginFlags for construction if needed.
PluginFlags string
+
+ // The genesis block from dex.Config
+ Genesis *core.Genesis
+
+ // Protocol options from dex.Config (partial)
+ NetworkID uint64
+ SyncMode downloader.SyncMode
}
// NewIndexerFromConfig initialize exporter according to given config.