forked from onflow/flow-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
46 lines (35 loc) · 2.25 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package storage
import (
"github.com/onflow/flow-go/model/flow"
)
// Events represents persistent storage for events.
type Events interface {
// Store will store events for the given block ID
Store(blockID flow.Identifier, blockEvents []flow.EventsList) error
// BatchStore will store events for the given block ID in a given batch
BatchStore(blockID flow.Identifier, events []flow.EventsList, batch BatchStorage) error
// ByBlockID returns the events for the given block ID
ByBlockID(blockID flow.Identifier) ([]flow.Event, error)
// ByBlockIDTransactionID returns the events for the given block ID and transaction ID
ByBlockIDTransactionID(blockID flow.Identifier, transactionID flow.Identifier) ([]flow.Event, error)
// ByBlockIDTransactionIndex returns the events for the transaction at given index in a given block
ByBlockIDTransactionIndex(blockID flow.Identifier, txIndex uint32) ([]flow.Event, error)
// ByBlockIDEventType returns the events for the given block ID and event type
ByBlockIDEventType(blockID flow.Identifier, eventType flow.EventType) ([]flow.Event, error)
// BatchRemoveByBlockID removes events keyed by a blockID in provided batch
// No errors are expected during normal operation, even if no entries are matched.
// If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned.
BatchRemoveByBlockID(blockID flow.Identifier, batch BatchStorage) error
}
type ServiceEvents interface {
// BatchStore stores service events keyed by a blockID in provided batch
// No errors are expected during normal operation, even if no entries are matched.
// If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned.
BatchStore(blockID flow.Identifier, events []flow.Event, batch BatchStorage) error
// ByBlockID returns the events for the given block ID
ByBlockID(blockID flow.Identifier) ([]flow.Event, error)
// BatchRemoveByBlockID removes service events keyed by a blockID in provided batch
// No errors are expected during normal operation, even if no entries are matched.
// If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned.
BatchRemoveByBlockID(blockID flow.Identifier, batch BatchStorage) error
}