Move Log to LogRes
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
)
|
||||
|
||||
type BlockRes struct {
|
||||
@ -211,3 +212,28 @@ type FilterWhisperRes struct {
|
||||
Payload string `json:"payload"`
|
||||
WorkProved string `json:"workProved"`
|
||||
}
|
||||
|
||||
type LogRes struct {
|
||||
Address string `json:"address"`
|
||||
Topic []string `json:"topic"`
|
||||
Data string `json:"data"`
|
||||
Number uint64 `json:"number"`
|
||||
}
|
||||
|
||||
func NewLogsRes(logs state.Logs) (ls []LogRes) {
|
||||
ls = make([]LogRes, len(logs))
|
||||
|
||||
for i, log := range logs {
|
||||
var l LogRes
|
||||
l.Topic = make([]string, len(log.Topics()))
|
||||
l.Address = common.ToHex(log.Address())
|
||||
l.Data = common.ToHex(log.Data())
|
||||
l.Number = log.Number()
|
||||
for j, topic := range log.Topics() {
|
||||
l.Topic[j] = common.ToHex(topic)
|
||||
}
|
||||
ls[i] = l
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user