aboutsummaryrefslogtreecommitdiffstats
path: root/dex/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'dex/backend.go')
-rw-r--r--dex/backend.go14
1 files changed, 14 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
}