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.

54 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. // EventSink interface is defined the APIs for the IndexerService to interact with the data store,
  15. // including the block/transaction indexing and the search functions.
  16. //
  17. // The IndexerService will accept a list of one or more EventSink types. During the OnStart method
  18. // it will call the appropriate APIs on each EventSink to index both block and transaction events.
  19. type EventSink interface {
  20. // IndexBlockEvents indexes the blockheader.
  21. IndexBlockEvents(types.EventDataNewBlockHeader) error
  22. // IndexTxEvents indexes the given result of transactions. To call it with multi transactions,
  23. // must guarantee the index of given transactions are in order.
  24. IndexTxEvents([]*abci.TxResult) error
  25. // SearchBlockEvents provides the block search by given query conditions. This function only
  26. // supported by the kvEventSink.
  27. SearchBlockEvents(context.Context, *query.Query) ([]int64, error)
  28. // SearchTxEvents provides the transaction search by given query conditions. This function only
  29. // supported by the kvEventSink.
  30. SearchTxEvents(context.Context, *query.Query) ([]*abci.TxResult, error)
  31. // GetTxByHash provides the transaction search by given transaction hash. This function only
  32. // supported by the kvEventSink.
  33. GetTxByHash([]byte) (*abci.TxResult, error)
  34. // HasBlock provides the transaction search by given transaction hash. This function only
  35. // supported by the kvEventSink.
  36. HasBlock(int64) (bool, error)
  37. // Type checks the eventsink structure type.
  38. Type() EventSinkType
  39. // Stop will close the data store connection, if the eventsink supports it.
  40. Stop() error
  41. }