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