aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorMeng-Ying Yang <garfield@dexon.org>2018-12-27 19:22:41 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:20 +0800
commit9da899a81e8c8e564fce464de77f6566dd818c2f (patch)
tree4fc1149be97de3c8a577247659d159a65f0fa921 /dex
parent980e57e46f0c7b29357baf31447871abff8192d6 (diff)
downloadgo-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar.gz
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar.bz2
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar.lz
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar.xz
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.tar.zst
go-tangerine-9da899a81e8c8e564fce464de77f6566dd818c2f.zip
indexer: support data exporting/forwarding (#103)
To support more effective and flexible blockchain info exploring, we add `indexer` package, defines the flow of indexer dameon, and integrate into dex.Dexon fullnode. For more export options, we use Golang built-in `plugin` package to support mulitple implementations.
Diffstat (limited to 'dex')
-rw-r--r--dex/backend.go14
-rw-r--r--dex/config.go5
2 files changed, 19 insertions, 0 deletions
diff --git a/dex/backend.go b/dex/backend.go
index 8fe38cd45..7b1f4905d 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -33,6 +33,7 @@ import (
"github.com/dexon-foundation/dexon/eth/gasprice"
"github.com/dexon-foundation/dexon/ethdb"
"github.com/dexon-foundation/dexon/event"
+ "github.com/dexon-foundation/dexon/indexer"
"github.com/dexon-foundation/dexon/internal/ethapi"
"github.com/dexon-foundation/dexon/log"
"github.com/dexon-foundation/dexon/node"
@@ -75,6 +76,8 @@ type Dexon struct {
networkID uint64
netRPCService *ethapi.PublicNetAPI
+
+ indexer indexer.Indexer
}
func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
@@ -132,6 +135,14 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
}
dex.bloomIndexer.Start(dex.blockchain)
+ if config.Indexer.Enable {
+ dex.indexer = indexer.NewIndexerFromConfig(
+ indexer.NewROBlockChain(dex.blockchain),
+ config.Indexer,
+ )
+ dex.indexer.Start()
+ }
+
if config.TxPool.Journal != "" {
config.TxPool.Journal = ctx.ResolvePath(config.TxPool.Journal)
}
@@ -241,6 +252,9 @@ func (s *Dexon) Start(srvr *p2p.Server) error {
func (s *Dexon) Stop() error {
s.bp.Stop()
s.app.Stop()
+ if s.indexer != nil {
+ s.indexer.Stop()
+ }
return nil
}
diff --git a/dex/config.go b/dex/config.go
index 5f148cc03..7661907cc 100644
--- a/dex/config.go
+++ b/dex/config.go
@@ -28,6 +28,7 @@ import (
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/dex/downloader"
"github.com/dexon-foundation/dexon/eth/gasprice"
+ "github.com/dexon-foundation/dexon/indexer"
"github.com/dexon-foundation/dexon/params"
)
@@ -48,6 +49,7 @@ var DefaultConfig = Config{
},
BlockProposerEnabled: false,
DefaultGasPrice: big.NewInt(params.GWei),
+ Indexer: indexer.Config{},
}
func init() {
@@ -121,4 +123,7 @@ type Config struct {
// Dexon options
DMoment int64
+
+ // Indexer config
+ Indexer indexer.Config
}