Browse Source

state/indexer: reconstruct indexer, move txindex into the indexer package (#6382)

pull/6387/head
JayT106 4 years ago
committed by GitHub
parent
commit
43eacd159f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 58 additions and 70 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +9
    -10
      node/node.go
  3. +1
    -2
      rpc/core/env.go
  4. +1
    -1
      rpc/core/tx.go
  5. +0
    -22
      state/indexer/block.go
  6. +16
    -3
      state/indexer/indexer.go
  7. +9
    -10
      state/indexer/indexer_service.go
  8. +4
    -4
      state/indexer/indexer_service_test.go
  9. +4
    -5
      state/indexer/tx/kv/kv.go
  10. +0
    -0
      state/indexer/tx/kv/kv_bench_test.go
  11. +10
    -10
      state/indexer/tx/kv/kv_test.go
  12. +0
    -0
      state/indexer/tx/kv/utils.go
  13. +0
    -0
      state/indexer/tx/kv/utils_test.go
  14. +3
    -3
      state/indexer/tx/null/null.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -16,6 +16,7 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- [rpc] \#6019 standardise RPC errors and return the correct status code (@bipulprasad & @cmwaters)
- [rpc] \#6168 Change default sorting to desc for `/tx_search` results (@melekes)
- [cli] \#6282 User must specify the node mode when using `tendermint init` (@cmwaters)
- [state/indexer] \#6382 reconstruct indexer, move txindex into the indexer package (@JayT106)
- Apps
- [ABCI] \#5447 Remove `SetOption` method from `ABCI.Client` interface


+ 9
- 10
node/node.go View File

@ -44,9 +44,8 @@ import (
"github.com/tendermint/tendermint/state/indexer"
blockidxkv "github.com/tendermint/tendermint/state/indexer/block/kv"
blockidxnull "github.com/tendermint/tendermint/state/indexer/block/null"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/state/txindex/kv"
"github.com/tendermint/tendermint/state/txindex/null"
"github.com/tendermint/tendermint/state/indexer/tx/kv"
"github.com/tendermint/tendermint/state/indexer/tx/null"
"github.com/tendermint/tendermint/statesync"
"github.com/tendermint/tendermint/store"
"github.com/tendermint/tendermint/types"
@ -226,9 +225,9 @@ type Node struct {
evidencePool *evidence.Pool // tracking evidence
proxyApp proxy.AppConns // connection to the application
rpcListeners []net.Listener // rpc servers
txIndexer txindex.TxIndexer
txIndexer indexer.TxIndexer
blockIndexer indexer.BlockIndexer
indexerService *txindex.IndexerService
indexerService *indexer.Service
prometheusSrv *http.Server
}
@ -267,10 +266,10 @@ func createAndStartIndexerService(
dbProvider DBProvider,
eventBus *types.EventBus,
logger log.Logger,
) (*txindex.IndexerService, txindex.TxIndexer, indexer.BlockIndexer, error) {
) (*indexer.Service, indexer.TxIndexer, indexer.BlockIndexer, error) {
var (
txIndexer txindex.TxIndexer
txIndexer indexer.TxIndexer
blockIndexer indexer.BlockIndexer
)
@ -288,7 +287,7 @@ func createAndStartIndexerService(
blockIndexer = &blockidxnull.BlockerIndexer{}
}
indexerService := txindex.NewIndexerService(txIndexer, blockIndexer, eventBus)
indexerService := indexer.NewIndexerService(txIndexer, blockIndexer, eventBus)
indexerService.SetLogger(logger.With("module", "txindex"))
if err := indexerService.Start(); err != nil {
@ -1736,7 +1735,7 @@ func (n *Node) Config() *cfg.Config {
}
// TxIndexer returns the Node's TxIndexer.
func (n *Node) TxIndexer() txindex.TxIndexer {
func (n *Node) TxIndexer() indexer.TxIndexer {
return n.txIndexer
}
@ -1760,7 +1759,7 @@ func (n *Node) NodeInfo() p2p.NodeInfo {
func makeNodeInfo(
config *cfg.Config,
nodeKey p2p.NodeKey,
txIndexer txindex.TxIndexer,
txIndexer indexer.TxIndexer,
genDoc *types.GenesisDoc,
state sm.State,
) (p2p.NodeInfo, error) {


+ 1
- 2
rpc/core/env.go View File

@ -14,7 +14,6 @@ import (
ctypes "github.com/tendermint/tendermint/rpc/core/types"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/state/indexer"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/types"
)
@ -83,7 +82,7 @@ type Environment struct {
// objects
PubKey crypto.PubKey
GenDoc *types.GenesisDoc // cache the genesis structure
TxIndexer txindex.TxIndexer
TxIndexer indexer.TxIndexer
BlockIndexer indexer.BlockIndexer
ConsensusReactor *consensus.Reactor
EventBus *types.EventBus // thread safe


+ 1
- 1
rpc/core/tx.go View File

@ -9,7 +9,7 @@ import (
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/state/txindex/null"
"github.com/tendermint/tendermint/state/indexer/tx/null"
"github.com/tendermint/tendermint/types"
)


+ 0
- 22
state/indexer/block.go View File

@ -1,22 +0,0 @@
package indexer
import (
"context"
"github.com/tendermint/tendermint/libs/pubsub/query"
"github.com/tendermint/tendermint/types"
)
// BlockIndexer defines an interface contract for indexing block events.
type BlockIndexer interface {
// Has returns true if the given height has been indexed. An error is returned
// upon database query failure.
Has(height int64) (bool, error)
// Index indexes BeginBlock and EndBlock events for a given block by its height.
Index(types.EventDataNewBlockHeader) error
// Search performs a query for block heights that match a given BeginBlock
// and Endblock event search criteria.
Search(ctx context.Context, q *query.Query) ([]int64, error)
}

state/txindex/indexer.go → state/indexer/indexer.go View File


state/txindex/indexer_service.go → state/indexer/indexer_service.go View File


state/txindex/indexer_service_test.go → state/indexer/indexer_service_test.go View File


state/txindex/kv/kv.go → state/indexer/tx/kv/kv.go View File


state/txindex/kv/kv_bench_test.go → state/indexer/tx/kv/kv_bench_test.go View File


state/txindex/kv/kv_test.go → state/indexer/tx/kv/kv_test.go View File


state/txindex/kv/utils.go → state/indexer/tx/kv/utils.go View File


state/txindex/kv/utils_test.go → state/indexer/tx/kv/utils_test.go View File


state/txindex/null/null.go → state/indexer/tx/null/null.go View File


Loading…
Cancel
Save