-
Notifications
You must be signed in to change notification settings - Fork 182
/
keeper.go
42 lines (35 loc) · 930 Bytes
/
keeper.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
package infura
import (
"github.com/okex/exchain/libs/tendermint/libs/log"
"github.com/okex/exchain/x/common/monitor"
evm "github.com/okex/exchain/x/evm/watcher"
)
// nolint
type Keeper struct {
metric *monitor.StreamMetrics
stream *Stream
}
// nolint
func NewKeeper(evmKeeper EvmKeeper, logger log.Logger, metrics *monitor.StreamMetrics) Keeper {
logger = logger.With("module", "infura")
k := Keeper{
metric: metrics,
stream: NewStream(logger),
}
if k.stream.enable {
evmKeeper.SetObserverKeeper(k)
}
return k
}
func (k Keeper) OnSaveTransactionReceipt(tr evm.TransactionReceipt) {
k.stream.cache.AddTransactionReceipt(tr)
}
func (k Keeper) OnSaveBlock(b evm.Block) {
k.stream.cache.AddBlock(b)
}
func (k Keeper) OnSaveTransaction(t evm.Transaction) {
k.stream.cache.AddTransaction(t)
}
func (k Keeper) OnSaveContractCode(address string, code []byte) {
k.stream.cache.AddContractCode(address, code)
}