2017-12-11 21:08:00 +00:00
|
|
|
package geth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/8thlight/vulcanizedb/pkg/core"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
2018-01-05 17:55:00 +00:00
|
|
|
func LogToCoreLog(gethLog types.Log) core.Log {
|
2017-12-11 21:08:00 +00:00
|
|
|
topics := gethLog.Topics
|
2017-12-12 21:55:26 +00:00
|
|
|
var hexTopics = make(map[int]string)
|
|
|
|
for i, topic := range topics {
|
|
|
|
hexTopics[i] = topic.Hex()
|
2017-12-11 21:08:00 +00:00
|
|
|
}
|
|
|
|
return core.Log{
|
|
|
|
Address: gethLog.Address.Hex(),
|
|
|
|
|
|
|
|
BlockNumber: int64(gethLog.BlockNumber),
|
|
|
|
Topics: hexTopics,
|
|
|
|
TxHash: gethLog.TxHash.Hex(),
|
2017-12-12 21:55:26 +00:00
|
|
|
Index: int64(gethLog.Index),
|
2017-12-11 21:08:00 +00:00
|
|
|
Data: hexutil.Encode(gethLog.Data),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GethLogsToCoreLogs(gethLogs []types.Log) []core.Log {
|
|
|
|
var logs []core.Log
|
|
|
|
for _, log := range gethLogs {
|
2018-01-05 17:55:00 +00:00
|
|
|
log := LogToCoreLog(log)
|
2017-12-11 21:08:00 +00:00
|
|
|
logs = append(logs, log)
|
|
|
|
}
|
|
|
|
return logs
|
|
|
|
}
|