-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathmodels.go
57 lines (50 loc) · 1.33 KB
/
models.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
47
48
49
50
51
52
53
54
55
56
57
package logpoller
import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/lib/pq"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)
// LogPollerBlock represents an unfinalized block
// used for reorg detection when polling.
type LogPollerBlock struct {
EvmChainId *utils.Big
BlockHash common.Hash
// Note geth uses int64 internally https://github.com/ethereum/go-ethereum/blob/f66f1a16b3c480d3a43ac7e8a09ab3e362e96ae4/eth/filters/api.go#L340
BlockNumber int64
BlockTimestamp time.Time
CreatedAt time.Time
}
// Log represents an EVM log.
type Log struct {
EvmChainId *utils.Big
LogIndex int64
BlockHash common.Hash
BlockNumber int64
BlockTimestamp time.Time
Topics pq.ByteaArray
EventSig common.Hash
Address common.Address
TxHash common.Hash
Data []byte
CreatedAt time.Time
}
func (l *Log) GetTopics() []common.Hash {
var tps []common.Hash
for _, topic := range l.Topics {
tps = append(tps, common.BytesToHash(topic))
}
return tps
}
func (l *Log) ToGethLog() types.Log {
return types.Log{
Data: l.Data,
Address: l.Address,
BlockHash: l.BlockHash,
BlockNumber: uint64(l.BlockNumber),
Topics: l.GetTopics(),
TxHash: l.TxHash,
Index: uint(l.LogIndex),
}
}