aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeng-Ying Yang <garfield@dexon.org>2019-01-02 16:32:43 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitfec4ee809e1f304376316445e58a8dae92a2ac7b (patch)
treecab78e75079871e09380dfbb360378c947602a98
parentf5a09dcb63dd5d0af3fa6d3d5346223b454ec561 (diff)
downloaddexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar.gz
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar.bz2
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar.lz
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar.xz
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.tar.zst
dexon-fec4ee809e1f304376316445e58a8dae92a2ac7b.zip
Indexer plugin extension and custom flags support (#117)
* indexer: ReadOnlyBlockchain returns underlying engine * indexer: plugin configs support custom flags
-rw-r--r--cmd/gdex/main.go1
-rw-r--r--cmd/gdex/usage.go1
-rw-r--r--cmd/utils/flags.go6
-rw-r--r--indexer/blockchain.go2
-rw-r--r--indexer/config.go3
5 files changed, 13 insertions, 0 deletions
diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go
index 2579e6f61..273c38838 100644
--- a/cmd/gdex/main.go
+++ b/cmd/gdex/main.go
@@ -139,6 +139,7 @@ var (
utils.EVMInterpreterFlag,
utils.IndexerEnableFlag,
utils.IndexerPluginFlag,
+ utils.IndexerPluginFlagsFlag,
configFileFlag,
}
diff --git a/cmd/gdex/usage.go b/cmd/gdex/usage.go
index 23afaa933..6427fd870 100644
--- a/cmd/gdex/usage.go
+++ b/cmd/gdex/usage.go
@@ -243,6 +243,7 @@ var AppHelpFlagGroups = []flagGroup{
Flags: []cli.Flag{
utils.IndexerEnableFlag,
utils.IndexerPluginFlag,
+ utils.IndexerPluginFlagsFlag,
},
},
{
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index ee5a3be6d..e4beb9cd4 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -654,6 +654,11 @@ var (
Usage: "External indexer plugin shared object path",
Value: "",
}
+ IndexerPluginFlagsFlag = cli.StringFlag{
+ Name: "indexer.plugin-flags",
+ Usage: "External indexer plugin's flags if needed",
+ Value: "",
+ }
)
// MakeDataDir retrieves the currently requested data directory, terminating
@@ -1297,6 +1302,7 @@ func setIndexerConfig(ctx *cli.Context, cfg *dex.Config) {
}
cfg.Indexer.Plugin = ctx.GlobalString(IndexerPluginFlag.Name)
+ cfg.Indexer.PluginFlags = ctx.GlobalString(IndexerPluginFlagsFlag.Name)
}
// SetDashboardConfig applies dashboard related command line flags to the config.
diff --git a/indexer/blockchain.go b/indexer/blockchain.go
index a762ef67d..421535184 100644
--- a/indexer/blockchain.go
+++ b/indexer/blockchain.go
@@ -7,6 +7,7 @@ import (
coreTypes "github.com/dexon-foundation/dexon-consensus/core/types"
"github.com/dexon-foundation/dexon/common"
+ "github.com/dexon-foundation/dexon/consensus"
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/core/state"
"github.com/dexon-foundation/dexon/core/types"
@@ -24,6 +25,7 @@ type ReadOnlyBlockChain interface {
CurrentBlock() *types.Block
CurrentFastBlock() *types.Block
CurrentHeader() *types.Header
+ Engine() consensus.Engine
GasLimit() uint64
Genesis() *types.Block
GetAncestor(common.Hash, uint64, uint64, *uint64) (common.Hash, uint64)
diff --git a/indexer/config.go b/indexer/config.go
index 3b626272a..396a23b66 100644
--- a/indexer/config.go
+++ b/indexer/config.go
@@ -11,6 +11,9 @@ type Config struct {
// Plugin path for building components.
Plugin string
+
+ // PluginFlags for construction if needed.
+ PluginFlags string
}
// NewIndexerFromConfig initialize exporter according to given config.