You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.9 KiB

  1. package indexer
  2. import (
  3. "context"
  4. abci "github.com/tendermint/tendermint/abci/types"
  5. "github.com/tendermint/tendermint/libs/pubsub/query"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. type EventSinkType string
  9. const (
  10. NULL EventSinkType = "null"
  11. KV EventSinkType = "kv"
  12. PSQL EventSinkType = "psql"
  13. )
  14. //go:generate ../../../scripts/mockery_generate.sh EventSink
  15. // EventSink interface is defined the APIs for the IndexerService to interact with the data store,
  16. // including the block/transaction indexing and the search functions.
  17. //
  18. // The IndexerService will accept a list of one or more EventSink types. During the OnStart method
  19. // it will call the appropriate APIs on each EventSink to index both block and transaction events.
  20. type EventSink interface {
  21. // IndexBlockEvents indexes the blockheader.
  22. IndexBlockEvents(types.EventDataNewBlockHeader) error
  23. // IndexTxEvents indexes the given result of transactions. To call it with multi transactions,
  24. // must guarantee the index of given transactions are in order.
  25. IndexTxEvents([]*abci.TxResult) error
  26. // SearchBlockEvents provides the block search by given query conditions. This function only
  27. // supported by the kvEventSink.
  28. SearchBlockEvents(context.Context, *query.Query) ([]int64, error)
  29. // SearchTxEvents provides the transaction search by given query conditions. This function only
  30. // supported by the kvEventSink.
  31. SearchTxEvents(context.Context, *query.Query) ([]*abci.TxResult, error)
  32. // GetTxByHash provides the transaction search by given transaction hash. This function only
  33. // supported by the kvEventSink.
  34. GetTxByHash([]byte) (*abci.TxResult, error)
  35. // HasBlock provides the transaction search by given transaction hash. This function only
  36. // supported by the kvEventSink.
  37. HasBlock(int64) (bool, error)
  38. // Type checks the eventsink structure type.
  39. Type() EventSinkType
  40. // Stop will close the data store connection, if the eventsink supports it.
  41. Stop() error
  42. }