-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_engine.go
32 lines (26 loc) · 1.14 KB
/
service_engine.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
package superwatcher
import (
"github.com/ethereum/go-ethereum/common"
)
// TODO: Artifact is too generic and this makes it hard
// for services to separate relevant artifacts.
type Artifact any
// BaseServiceEngine is shared by ServiceEngine and ServiceThinEngine
type BaseServiceEngine interface {
HandleEmitterError(error) error
}
// ServiceEngine is embedded and injected into Engine to perform business logic.
// It is the preferred way to use superwatcher
type ServiceEngine interface {
BaseServiceEngine
// HandleGoodLogs handles new, canonical `Block`s. The return type is map of blockHash to []Artifact
HandleGoodBlocks([]*Block, []Artifact) (map[common.Hash][]Artifact, error)
// HandleReorgedLogs handles reorged (removed) `Block`s. The return type is map of blockHash to []Artifact
HandleReorgedBlocks([]*Block, []Artifact) (map[common.Hash][]Artifact, error)
}
// ThinServiceEngine is embedded and injected into thinEngine, a thin implementation of Engine without managed states.
// It is recommended for niche use cases and advanced users
type ThinServiceEngine interface {
BaseServiceEngine
HandleFilterResult(*PollerResult) error
}