ipld-eth-server/core/block.go
Matt K c961e85099 Refactor block conversion (#38)
Move more of block conversion out of observer
2017-10-31 12:51:05 -05:00

28 lines
661 B
Go

package core
import (
"github.com/ethereum/go-ethereum/core/types"
)
type Block struct {
Number int64
GasLimit int64
GasUsed int64
Time int64
Transactions []Transaction
}
func GethBlockToCoreBlock(gethBlock *types.Block) Block {
transactions := []Transaction{}
for _, gethTransaction := range gethBlock.Transactions() {
transactions = append(transactions, gethTransToCoreTrans(gethTransaction))
}
return Block{
Number: gethBlock.Number().Int64(),
GasLimit: gethBlock.GasLimit().Int64(),
GasUsed: gethBlock.GasUsed().Int64(),
Time: gethBlock.Time().Int64(),
Transactions: transactions,
}
}